Initial commit

This commit is contained in:
Almira Krdzic
2018-08-06 15:41:19 +02:00
commit 60fe7f93e5
217 changed files with 84900 additions and 0 deletions

View File

@@ -0,0 +1,473 @@
<?php
/**
* Gravity Flow Common Step Settings Functions
*
* @package GravityFlow
* @copyright Copyright (c) 2015-2018, Steven Henty S.L.
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
* @since 1.5.1-dev
*/
if ( ! class_exists( 'GFForms' ) ) {
die();
}
/**
* Class Gravity_Flow_Common_Step_Settings
*/
class Gravity_Flow_Common_Step_Settings {
/**
* Choices array of assignees.
*
* @var array
*/
private $_account_choices = array();
/**
* Choices array of active Gravity PDF feeds.
*
* @var array
*/
private $_gpdf_choices = array();
/**
* Gravity_Flow_Common_Step_Settings constructor.
*/
public function __construct() {
$this->_account_choices = gravity_flow()->get_users_as_choices();
$this->set_gpdf_choices();
}
/**
* If Gravity PDF 4 is active prepare a choices array of active PDF feeds for the current form.
*
* @since 1.5.1-dev
*/
public function set_gpdf_choices() {
if ( defined( 'PDF_EXTENDED_VERSION' ) && version_compare( PDF_EXTENDED_VERSION, '4.0-RC2', '>=' ) ) {
$form_id = rgget( 'id' );
$gpdf_feeds = GPDFAPI::get_form_pdfs( $form_id );
if ( ! is_wp_error( $gpdf_feeds ) ) {
/* Format the PDFs in the appropriate format for use in a select field */
foreach ( $gpdf_feeds as $gpdf_feed ) {
if ( true === $gpdf_feed['active'] ) {
$this->_gpdf_choices[] = array( 'label' => $gpdf_feed['name'], 'value' => $gpdf_feed['id'] );
}
}
}
}
}
/**
* Get the choices array for the type setting.
*
* @since 1.5.1-dev
*
* @return array
*/
public function get_type_choices() {
return array(
array( 'label' => __( 'Select', 'gravityflow' ), 'value' => 'select' ),
array( 'label' => __( 'Conditional Routing', 'gravityflow' ), 'value' => 'routing' ),
);
}
/**
* Get the enable notification field.
*
* @since 1.5.1-dev
*
* @param array $config The notification settings properties.
*
* @return array
*/
public function get_notification_enabled_field( $config ) {
return array(
array(
'name' => $config['name_prefix'] . '_notification_enabled',
'label' => $config['label'],
'tooltip' => $config['tooltip'],
'type' => 'checkbox',
'choices' => array(
array(
'label' => $config['checkbox_label'],
'tooltip' => $config['checkbox_tooltip'],
'name' => $config['name_prefix'] . '_notification_enabled',
'default_value' => $config['checkbox_default_value'],
),
),
),
);
}
/**
* Get the notification "Send To" settings.
*
* @since 1.5.1-dev
*
* @param array $config The notification settings properties.
*
* @return array
*/
public function get_notification_send_to_fields( $config ) {
if ( ! rgar( $config, 'send_to_fields' ) ) {
return array();
}
$prefix = rgar( $config, 'name_prefix' );
return array(
array(
'name' => $prefix . '_notification_type',
'label' => __( 'Send To', 'gravityflow' ),
'type' => 'radio',
'default_value' => 'select',
'horizontal' => true,
'choices' => $this->get_type_choices(),
),
array(
'id' => $prefix . '_notification_users',
'name' => $prefix . '_notification_users[]',
'label' => __( 'Select', 'gravityflow' ),
'size' => '8',
'multiple' => 'multiple',
'type' => 'select',
'choices' => $this->_account_choices,
),
array(
'name' => $prefix . '_notification_routing',
'label' => __( 'Routing', 'gravityflow' ),
'class' => 'large',
'type' => 'user_routing',
)
);
}
/**
* Get the common notification fields.
*
* @since 1.5.1-dev
*
* @param array $config The notification settings properties.
*
* @return array
*/
public function get_notification_common_fields( $config ) {
$prefix = rgar( $config, 'name_prefix' );
return array(
array(
'name' => $prefix . '_notification_from_name',
'label' => __( 'From Name', 'gravityflow' ),
'class' => 'fieldwidth-2 merge-tag-support mt-hide_all_fields mt-position-right ui-autocomplete-input',
'type' => 'text',
),
array(
'name' => $prefix . '_notification_from_email',
'label' => __( 'From Email', 'gravityflow' ),
'class' => 'fieldwidth-2 merge-tag-support mt-hide_all_fields mt-position-right ui-autocomplete-input',
'type' => 'text',
'default_value' => '{admin_email}',
),
array(
'name' => $prefix . '_notification_reply_to',
'class' => 'fieldwidth-2 merge-tag-support mt-hide_all_fields mt-position-right ui-autocomplete-input',
'label' => __( 'Reply To', 'gravityflow' ),
'type' => 'text',
),
array(
'name' => $prefix . '_notification_bcc',
'class' => 'fieldwidth-2 merge-tag-support mt-hide_all_fields mt-position-right ui-autocomplete-input',
'label' => __( 'BCC', 'gravityflow' ),
'type' => 'text',
),
array(
'name' => $prefix . '_notification_subject',
'class' => 'fieldwidth-1 merge-tag-support mt-hide_all_fields mt-position-right ui-autocomplete-input',
'label' => __( 'Subject', 'gravityflow' ),
'type' => 'text',
),
array(
'name' => $prefix . '_notification_message',
'label' => __( 'Message', 'gravityflow' ),
'type' => 'visual_editor',
'default_value' => rgar( $config, 'default_message' ),
),
array(
'name' => $prefix . '_notification_autoformat',
'label' => '',
'type' => 'checkbox',
'choices' => array(
array(
'label' => __( 'Disable auto-formatting', 'gravityflow' ),
'name' => $prefix . '_notification_disable_autoformat',
'default_value' => false,
'tooltip' => __( 'Disable auto-formatting to prevent paragraph breaks being automatically inserted when using HTML to create the email message.', 'gravityflow' ),
),
),
),
);
}
/**
* Get the resend notification field.
*
* @since 1.5.1-dev
*
* @param array $config The notification settings properties.
*
* @return array
*/
public function get_notification_resend_field( $config ) {
if ( ! rgar( $config, 'resend_field' ) ) {
return array();
}
$prefix = rgar( $config, 'name_prefix' );
return array(
array(
'name' => $prefix . '_notification_resend',
'label' => '',
'type' => 'checkbox_and_container',
'checkbox' => array(
'label' => __( 'Send reminder', 'gravityflow' ),
'name' => 'resend_assignee_emailEnable'
),
'settings' => array(
array(
'name' => 'resend_assignee_emailValue',
'label' => esc_html__( 'Reminder', 'gravityflow' ),
'type' => 'text',
'before' => esc_html__( 'Resend the assignee email after', 'gravityflow' ) . ' ',
'after' => ' ' . esc_html__( 'day(s)', 'gravityflow' ),
'default_value' => 7,
'class' => 'small-text',
),
array(
'name' => 'resend_assignee_email_repeat',
'label' => '',
'type' => 'checkbox_and_text',
'before' => '<br />',
'checkbox' => array(
'label' => esc_html__( 'Repeat reminder', 'gravityflow' ),
),
'text' => array(
'default_value' => 3,
'class' => 'small-text',
'before' => esc_html__( 'Repeat every', 'gravityflow' ) . ' ',
'after' => ' ' . esc_html__( 'day(s)', 'gravityflow' ),
),
),
),
),
);
}
/**
* Get the "Attach PDF" notification field.
*
* @since 1.5.1-dev
*
* @param array $config The notification settings properties.
*
* @return array
*/
public function get_notification_gpdf_field( $config ) {
if ( empty( $this->_gpdf_choices ) ) {
return array();
}
return array(
array(
'name' => rgar( $config, 'name_prefix' ) . '_notification_gpdf',
'label' => '',
'type' => 'checkbox_and_select',
'checkbox' => array(
'label' => esc_html__( 'Attach PDF', 'gravityflow' ),
),
'select' => array(
'choices' => $this->_gpdf_choices,
),
)
);
}
/**
* Get the properties for the fields which appear on one notification tab.
*
* @since 1.5.1-dev
*
* @param array $config The notification settings properties.
*
* @return array
*/
public function get_setting_notification( $config = array() ) {
$config = array_merge( array(
'name_prefix' => 'assignee',
'label' => '',
'tooltip' => '',
'checkbox_label' => __( 'Send an email to the assignee', 'gravityflow' ),
'checkbox_tooltip' => __( 'Enable this setting to send email to each of the assignees as soon as the entry has been assigned. If a role is configured to receive emails then all the users with that role will receive the email.', 'gravityflow' ),
'checkbox_default_value' => false,
'default_message' => '',
'send_to_fields' => false,
'resend_field' => true,
), $config );
$fields = array_merge(
$this->get_notification_enabled_field( $config ),
$this->get_notification_send_to_fields( $config ),
$this->get_notification_common_fields( $config ),
$this->get_notification_resend_field( $config ),
$this->get_notification_gpdf_field( $config )
);
return $fields;
}
/**
* Get the properties for the notification tabs setting.
*
* @since 1.5.1-dev
*
* @param array $tabs The properties for each tab.
*
* @return array
*/
public function get_setting_notification_tabs( $tabs ) {
return array(
'name' => 'notification_tabs',
'label' => __( 'Emails', 'gravityflow' ),
'tooltip' => __( 'Configure the emails that should be sent for this step.', 'gravityflow' ),
'type' => 'tabs',
'tabs' => $tabs,
);
}
/**
* Get the properties for the assignee type field.
*
* @since 1.5.1-dev
*
* @return array
*/
public function get_setting_assignee_type() {
return array(
'name' => 'type',
'label' => __( 'Assign To:', 'gravityflow' ),
'type' => 'radio',
'default_value' => 'select',
'horizontal' => true,
'choices' => $this->get_type_choices(),
);
}
/**
* Get the properties for the assignees field.
*
* @since 1.5.1-dev
*
* @return array
*/
public function get_setting_assignees() {
return array(
'id' => 'assignees',
'name' => 'assignees[]',
'tooltip' => __( 'Users and roles fields will appear in this list. If the form contains any assignee fields they will also appear here. Click on an item to select it. The selected items will appear on the right. If you select a role then anybody from that role can approve.', 'gravityflow' ),
'size' => '8',
'multiple' => 'multiple',
'label' => esc_html__( 'Select Assignees', 'gravityflow' ),
'type' => 'select',
'choices' => $this->_account_choices,
);
}
/**
* Get the properties for the assignee routing field.
*
* @since 1.5.1-dev
*
* @return array
*/
public function get_setting_assignee_routing() {
return array(
'name' => 'routing',
'tooltip' => __( 'Build assignee routing rules by adding conditions. Users and roles fields will appear in the first drop-down field. If the form contains any assignee fields they will also appear here. Select the assignee and define the condition for that assignee. Add as many routing rules as you need.', 'gravityflow' ),
'label' => __( 'Routing', 'gravityflow' ),
'type' => 'routing',
);
}
/**
* Get the properties for the instructions field.
*
* @since 1.5.1-dev
*
* @param string $default_value The default value to appear in the editor.
*
* @return array
*/
public function get_setting_instructions( $default_value = '' ) {
return array(
'name' => 'instructions',
'label' => __( 'Instructions', 'gravityflow' ),
'type' => 'checkbox_and_textarea',
'tooltip' => esc_html__( 'Activate this setting to display instructions to the user for the current step.', 'gravityflow' ),
'checkbox' => array(
'label' => esc_html__( 'Display instructions', 'gravityflow' ),
),
'textarea' => array(
'use_editor' => true,
'default_value' => $default_value,
),
);
}
/**
* Get the properties for the display fields type field.
*
* @since 1.5.1-dev
*
* @return array
*/
public function get_setting_display_fields() {
return array(
'name' => 'display_fields',
'label' => __( 'Display Fields', 'gravityflow' ),
'tooltip' => __( 'Select the fields to hide or display.', 'gravityflow' ),
'type' => 'display_fields',
);
}
/**
* Get the properties for the confirmation message setting.
*
* @since 1.5.1-dev
*
* @param string $default_value The default value to appear in the editor.
*
* @return array
*/
public function get_setting_confirmation_messasge( $default_value = '' ) {
return array(
'name' => 'confirmation_message',
'label' => __( 'Confirmation Message', 'gravityflow' ),
'type' => 'checkbox_and_textarea',
'tooltip' => esc_html__( 'Activate this setting to display a custom confirmation message to the assignee for the current step.', 'gravityflow' ),
'checkbox' => array(
'label' => esc_html__( 'Display a custom confirmation message', 'gravityflow' ),
),
'textarea' => array(
'use_editor' => true,
'default_value' => $default_value,
),
);
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,67 @@
<?php
/**
* Gravity Flow Step Feed ActiveCampaign
*
* @package GravityFlow
* @subpackage Classes/Gravity_Flow_Step_Feed_ActiveCampaign
* @copyright Copyright (c) 2016-2018, Steven Henty S.L.
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
* @since 1.3.1.2
*/
if ( ! class_exists( 'GFForms' ) ) {
die();
}
/**
* Class Gravity_Flow_Step_Feed_ActiveCampaign
*/
class Gravity_Flow_Step_Feed_ActiveCampaign extends Gravity_Flow_Step_Feed_Add_On {
/**
* The step type.
*
* @var string
*/
public $_step_type = 'activecampaign';
/**
* The name of the class used by the add-on.
*
* @var string
*/
protected $_class_name = 'GFActiveCampaign';
/**
* Returns the step label.
*
* @return string
*/
public function get_label() {
return 'ActiveCampaign';
}
/**
* Returns the feed name.
*
* @param array $feed The ActiveCampaign feed properties.
*
* @return string
*/
public function get_feed_label( $feed ) {
$label = $feed['meta']['feed_name'];
return $label;
}
/**
* Returns the URL for the step icon.
*
* @return string
*/
public function get_icon_url() {
return $this->get_base_url() . '/images/activecampaign-icon.svg';
}
}
Gravity_Flow_Steps::register( new Gravity_Flow_Step_Feed_ActiveCampaign() );

View File

@@ -0,0 +1,426 @@
<?php
/**
* Gravity_Flow_Step_Feed_Add_On
*
* @package GravityFlow
* @subpackage Classes/Step_Feed_Add_On
* @copyright Copyright (c) 2015-2018, Steven Henty S.L.
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
* @since 1.0
*/
if ( ! class_exists( 'GFForms' ) ) {
die();
}
/**
* Abstract class to be used for integration with Gravity Forms Feed Add-Ons.
* Extend this class to integrate any Gravity Forms Add-On that is built using the Feed-Add-On Framework.
*
* Register your extending class using Gravity_Flow_Steps::register().
* example:
* Gravity_Flow_Steps::register( new Gravity_Flow_Step_My_Feed_Add_On_Step() )
*
* Class Gravity_Flow_Step_Feed_Add_On
*
* @since 1.0
*/
abstract class Gravity_Flow_Step_Feed_Add_On extends Gravity_Flow_Step {
/**
* The name of the class used by the add-on. Example: GFMailChimp.
*
* @var string
*/
protected $_class_name = '';
/**
* The add-on slug. Example: gravityformsmailchimp.
*
* @var string
*/
protected $_slug = '';
/**
* The feeds processed for the current entry.
*
* @var array
*/
private $_processed_feeds = array();
/**
* Returns the class name for the add-on.
*
* @return string
*/
public function get_feed_add_on_class_name() {
return $this->_class_name;
}
/**
* Is this feed step supported on this server? Override to hide this step in the list of step types if the requirements are not met.
*
* @return bool
*/
public function is_supported() {
$is_supported = true;
$feed_add_on_class = $this->get_feed_add_on_class_name();
if ( ! class_exists( $feed_add_on_class ) ) {
$is_supported = false;
}
return $is_supported;
}
/**
* Returns the settings for this step.
*
* @return array
*/
public function get_settings() {
$fields = array();
if ( ! $this->is_supported() ) {
return $fields;
}
$feeds = $this->get_feeds();
$feed_choices = array();
foreach ( $feeds as $feed ) {
if ( $feed['is_active'] ) {
$label = $this->get_feed_label( $feed );
$feed_choices[] = array(
'label' => $label,
'name' => 'feed_' . $feed['id'],
);
}
}
if ( ! empty( $feed_choices ) ) {
$fields[] = array(
'name' => 'feeds',
'required' => true,
'label' => esc_html__( 'Feeds', 'gravityflow' ),
'type' => 'checkbox',
'choices' => $feed_choices,
);
}
if ( empty( $fields ) ) {
$html = esc_html__( "You don't have any feeds set up.", 'gravityflow' );
$fields[] = array(
'name' => 'no_feeds',
'label' => esc_html__( 'Feeds', 'gravityflow' ),
'type' => 'html',
'html' => $html,
);
}
return array(
'title' => $this->get_label(),
'fields' => $fields,
);
}
/**
* Processes this step.
*
* @return bool Is the step complete?
*/
public function process() {
$form = $this->get_form();
$entry = $this->get_entry();
$complete = true;
$add_on_feeds = $this->get_processed_add_on_feeds();
$feeds = $this->get_feeds();
foreach ( $feeds as $feed ) {
$setting_key = 'feed_' . $feed['id'];
if ( $this->{$setting_key} ) {
if ( $this->is_feed_condition_met( $feed, $form, $entry ) ) {
$complete = $this->process_feed( $feed );
$label = $this->get_feed_label( $feed );
if ( $complete ) {
$note = sprintf( esc_html__( 'Processed: %s', 'gravityflow' ), $label );
$this->log_debug( __METHOD__ . '() - Feed processed: ' . $label );
$add_on_feeds = $this->maybe_set_processed_feed( $add_on_feeds, $feed['id'] );
} else {
$note = sprintf( esc_html__( 'Initiated: %s', 'gravityflow' ), $label );
$this->log_debug( __METHOD__ . '() - Feed processing initiated: ' . $label );
$add_on_feeds = $this->maybe_unset_processed_feed( $add_on_feeds, $feed['id'] );
}
$this->add_note( $note );
} else {
$this->log_debug( __METHOD__ . '() - Feed condition not met' );
}
}
}
$this->update_processed_feeds( $add_on_feeds );
return $complete;
}
/**
* Returns the feeds for the add-on.
*
* @return array|mixed
*/
public function get_feeds() {
$form_id = $this->get_form_id();
if ( $this->is_supported() ) {
/* @var GFFeedAddOn $add_on */
$add_on = $this->get_add_on_instance();
$feeds = $add_on->get_feeds( $form_id );
} else {
$feeds = array();
}
return $feeds;
}
/**
* Processes the given feed for the add-on.
*
* @param array $feed The add-on feed properties.
*
* @return bool Is feed processing complete?
*/
public function process_feed( $feed ) {
$form = $this->get_form();
$entry = $this->get_entry();
$add_on = $this->get_add_on_instance();
$add_on->process_feed( $feed, $entry, $form );
return true;
}
/**
* Prevent the feeds assigned to the current step from being processed by the associated add-on.
*/
public function intercept_submission() {
$form_id = $this->get_form_id();
$slug = $this->get_slug();
add_filter( "gform_{$slug}_pre_process_feeds_{$form_id}", array( $this, 'pre_process_feeds' ), 10, 2 );
}
/**
* Returns the label of the given feed.
*
* @param array $feed The add-on feed properties.
*
* @return string
*/
public function get_feed_label( $feed ) {
$label = $feed['meta']['feedName'];
return $label;
}
/**
* Determines if the supplied feed should be processed.
*
* @param array $feed The current feed.
* @param array $form The current form.
* @param array $entry The current entry.
*
* @return bool
*/
public function is_feed_condition_met( $feed, $form, $entry ) {
return gravity_flow()->is_feed_condition_met( $feed, $form, $entry );
}
/**
* Retrieve an instance of the add-on associated with this step.
*
* @return GFFeedAddOn
*/
public function get_add_on_instance() {
$add_on = call_user_func( array( $this->get_feed_add_on_class_name(), 'get_instance' ) );
return $add_on;
}
/**
* Remove the feeds assigned to the current step from the array to be processed by the associated add-on.
*
* @param array $feeds An array of $feed objects for the add-on currently being processed.
* @param array $entry The entry object currently being processed.
*
* @return array
*/
public function pre_process_feeds( $feeds, $entry ) {
if ( is_array( $feeds ) ) {
foreach ( $feeds as $key => $feed ) {
$setting_key = 'feed_' . $feed['id'];
if ( $this->{$setting_key} ) {
$this->get_add_on_instance()->log_debug( __METHOD__ . "(): Delaying feed (#{$feed['id']} - {$this->get_feed_label( $feed )}) for entry #{$entry['id']}." );
$this->get_add_on_instance()->delay_feed( $feed, $entry, $this->get_form() );
unset( $feeds[ $key ] );
}
}
}
return $feeds;
}
/**
* Ensure active steps are not processed if the associated add-on is not available.
*
* @return bool
*/
public function is_active() {
$is_active = parent::is_active();
if ( $is_active && ! $this->is_supported() ) {
$is_active = false;
}
return $is_active;
}
/**
* Get the slug for the add-on associated with this step.
*
* @return string
*/
public function get_slug() {
if ( empty( $this->_slug ) ) {
$this->_slug = $this->get_add_on_instance()->get_slug();
}
return $this->_slug;
}
/**
* Retrieve an array containing the IDs of all the feeds processed for the current entry.
*
* @param bool|int $entry_id False or the ID of the entry the meta should be retrieved from.
*
* @return array
*/
public function get_processed_feeds( $entry_id = false ) {
if ( ! empty( $this->_processed_feeds ) ) {
return $this->_processed_feeds;
}
if ( ! $entry_id ) {
$entry_id = $this->get_entry_id();
}
$processed_feeds = gform_get_meta( $entry_id, 'processed_feeds' );
if ( empty( $processed_feeds ) ) {
$processed_feeds = array();
}
$this->_processed_feeds = $processed_feeds;
return $processed_feeds;
}
/**
* Retrieve an array of this add-ons feed IDs which have been processed for the current entry.
*
* @param bool|int $entry_id False or the ID of the entry the meta should be retrieved from.
*
* @return array
*/
public function get_processed_add_on_feeds( $entry_id = false ) {
$processed_feeds = $this->get_processed_feeds( $entry_id );
$add_on_feeds = rgar( $processed_feeds, $this->get_slug() );
if ( empty( $add_on_feeds ) ) {
$add_on_feeds = array();
}
return $add_on_feeds;
}
/**
* Add the ID of the current feed to the processed feeds array for the current add-on.
*
* @param array $add_on_feeds The IDs of the processed feeds.
* @param int $feed_id The ID of the processed feed.
*
* @return array
*/
public function maybe_set_processed_feed( $add_on_feeds, $feed_id ) {
if ( ! in_array( $feed_id, $add_on_feeds ) ) {
$add_on_feeds[] = $feed_id;
}
return $add_on_feeds;
}
/**
* If necessary remove the current feed from the processed feeds array for the current add-on.
*
* @param array $add_on_feeds The IDs of the processed feeds.
* @param int $feed_id The ID of the processed feed.
*
* @return array
*/
public function maybe_unset_processed_feed( $add_on_feeds, $feed_id ) {
foreach ( $add_on_feeds as $key => $id ) {
if ( $id == $feed_id ) {
unset( $add_on_feeds[ $key ] );
break;
}
}
return $add_on_feeds;
}
/**
* Update the processed_feeds array for the current entry.
*
* @param array $add_on_feeds The IDs of the processed feeds for the current add-on.
* @param bool|int $entry_id False or the ID of the entry the meta should be saved for.
*/
public function update_processed_feeds( $add_on_feeds, $entry_id = false ) {
if ( ! $entry_id ) {
$entry_id = $this->get_entry_id();
}
$processed_feeds = $this->get_processed_feeds( $entry_id );
$processed_feeds[ $this->get_slug() ] = $add_on_feeds;
$this->_processed_feeds = $processed_feeds;
gform_update_meta( $entry_id, 'processed_feeds', $processed_feeds );
}
/**
* Evaluates the status for the step.
*
* The step is only complete when all the feeds for this step have been added to the entry meta processed_feeds array.
*
* @return string 'pending' or 'complete'
*/
public function status_evaluation() {
$add_on_feeds = $this->get_processed_add_on_feeds();
$feeds = $this->get_feeds();
$form = $this->get_form();
$entry = $this->get_entry();
foreach ( $feeds as $feed ) {
$setting_key = 'feed_' . $feed['id'];
if ( $this->{$setting_key} && ! in_array( $feed['id'], $add_on_feeds ) && $this->is_feed_condition_met( $feed, $form, $entry ) ) {
return 'pending';
}
}
return 'complete';
}
}

View File

@@ -0,0 +1,54 @@
<?php
/**
* Gravity Flow Step Feed Agile CRM
*
* @package GravityFlow
* @subpackage Classes/Gravity_Flow_Step_Feed_AgileCRM
* @copyright Copyright (c) 2016-2018, Steven Henty S.L.
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
* @since 1.3.1.4
*/
if ( ! class_exists( 'GFForms' ) ) {
die();
}
/**
* Class Gravity_Flow_Step_Feed_AgileCRM
*/
class Gravity_Flow_Step_Feed_AgileCRM extends Gravity_Flow_Step_Feed_Add_On {
/**
* The step type.
*
* @var string
*/
public $_step_type = 'agilecrm';
/**
* The name of the class used by the add-on.
*
* @var string
*/
protected $_class_name = 'GFAgileCRM';
/**
* Returns the step label.
*
* @return string
*/
public function get_label() {
return 'Agile CRM';
}
/**
* Returns the URL for the step icon.
*
* @return string
*/
public function get_icon_url() {
return $this->get_base_url() . '/images/agilecrm-icon.svg';
}
}
Gravity_Flow_Steps::register( new Gravity_Flow_Step_Feed_AgileCRM() );

View File

@@ -0,0 +1,46 @@
<?php
/**
* Gravity Flow Step Feed AWeber
*
* @package GravityFlow
* @subpackage Classes/Gravity_Flow_Step_Feed_AWeber
* @copyright Copyright (c) 2016-2018, Steven Henty S.L.
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
* @since 1.3.1.4
*/
if ( ! class_exists( 'GFForms' ) ) {
die();
}
/**
* Class Gravity_Flow_Step_Feed_AWeber
*/
class Gravity_Flow_Step_Feed_AWeber extends Gravity_Flow_Step_Feed_Add_On {
/**
* The step type.
*
* @var string
*/
public $_step_type = 'aweber';
/**
* The name of the class used by the add-on.
*
* @var string
*/
protected $_class_name = 'GFAWeber';
/**
* Returns the step label.
*
* @return string
*/
public function get_label() {
return 'AWeber';
}
}
Gravity_Flow_Steps::register( new Gravity_Flow_Step_Feed_AWeber() );

View File

@@ -0,0 +1,58 @@
<?php
/**
* Gravity Flow Step Feed Batchbook
*
* @package GravityFlow
* @subpackage Classes/Gravity_Flow_Step_Feed_Batchbook
* @copyright Copyright (c) 2016-2018, Steven Henty S.L.
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
* @since 1.3.1.4
*/
if ( ! class_exists( 'GFForms' ) ) {
die();
}
/**
* Class Gravity_Flow_Step_Feed_Batchbook
*/
class Gravity_Flow_Step_Feed_Batchbook extends Gravity_Flow_Step_Feed_Add_On {
/**
* The step type.
*
* @var string
*/
public $_step_type = 'batchbook';
/**
* The name of the class used by the add-on.
*
* @var string
*/
protected $_class_name = 'GFBatchbook';
/**
* Returns the step label.
*
* @return string
*/
public function get_label() {
return 'Batchbook';
}
/**
* Returns the feed name.
*
* @param array $feed The Batchbook feed properties.
*
* @return string
*/
public function get_feed_label( $feed ) {
$label = $feed['meta']['feed_name'];
return $label;
}
}
Gravity_Flow_Steps::register( new Gravity_Flow_Step_Feed_Batchbook() );

View File

@@ -0,0 +1,54 @@
<?php
/**
* Gravity Flow Step Feed Breeze
*
* @package GravityFlow
* @subpackage Classes/Gravity_Flow_Step_Feed_Breeze
* @copyright Copyright (c) 2016-2018, Steven Henty S.L.
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
* @since 1.3.3-dev
*/
if ( ! class_exists( 'GFForms' ) ) {
die();
}
/**
* Class Gravity_Flow_Step_Feed_Breeze
*/
class Gravity_Flow_Step_Feed_Breeze extends Gravity_Flow_Step_Feed_Add_On {
/**
* The step type.
*
* @var string
*/
public $_step_type = 'breeze';
/**
* The name of the class used by the add-on.
*
* @var string
*/
protected $_class_name = 'GF_Breeze';
/**
* Returns the step label.
*
* @return string
*/
public function get_label() {
return 'Breeze';
}
/**
* Returns the URL for the step icon.
*
* @return string
*/
public function get_icon_url() {
return $this->get_base_url() . '/images/breeze-icon.svg';
}
}
Gravity_Flow_Steps::register( new Gravity_Flow_Step_Feed_Breeze() );

View File

@@ -0,0 +1,45 @@
<?php
/**
* Gravity Flow Step Feed Campaign Monitor
*
* @package GravityFlow
* @subpackage Classes/Gravity_Flow_Step_Feed_Campaign_Monitor
* @copyright Copyright (c) 2015-2018, Steven Henty S.L.
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
* @since 1.0
*/
if ( ! class_exists( 'GFForms' ) ) {
die();
}
/**
* Class Gravity_Flow_Step_Feed_Campaign_Monitor
*/
class Gravity_Flow_Step_Feed_Campaign_Monitor extends Gravity_Flow_Step_Feed_Add_On {
/**
* The step type.
*
* @var string
*/
public $_step_type = 'campaign_monitor';
/**
* The name of the class used by the add-on.
*
* @var string
*/
protected $_class_name = 'GFCampaignMonitor';
/**
* Returns the step label.
*
* @return string
*/
public function get_label() {
return 'Campaign Monitor';
}
}
Gravity_Flow_Steps::register( new Gravity_Flow_Step_Feed_Campaign_Monitor() );

View File

@@ -0,0 +1,46 @@
<?php
/**
* Gravity Flow Step Feed Campfire
*
* @package GravityFlow
* @subpackage Classes/Gravity_Flow_Step_Feed_Campfire
* @copyright Copyright (c) 2016-2018, Steven Henty S.L.
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
* @since 1.3.1.4
*/
if ( ! class_exists( 'GFForms' ) ) {
die();
}
/**
* Class Gravity_Flow_Step_Feed_Campfire
*/
class Gravity_Flow_Step_Feed_Campfire extends Gravity_Flow_Step_Feed_Add_On {
/**
* The step type.
*
* @var string
*/
public $_step_type = 'campfire';
/**
* The name of the class used by the add-on.
*
* @var string
*/
protected $_class_name = 'GFCampfire';
/**
* Returns the step label.c
*
* @return string
*/
public function get_label() {
return 'Campfire';
}
}
Gravity_Flow_Steps::register( new Gravity_Flow_Step_Feed_Campfire() );

View File

@@ -0,0 +1,58 @@
<?php
/**
* Gravity Flow Step Feed Capsule CRM
*
* @package GravityFlow
* @subpackage Classes/Gravity_Flow_Step_Feed_CapsuleCRM
* @copyright Copyright (c) 2016-2018, Steven Henty S.L.
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
* @since 1.3.1.6
*/
if ( ! class_exists( 'GFForms' ) ) {
die();
}
/**
* Class Gravity_Flow_Step_Feed_CapsuleCRM
*/
class Gravity_Flow_Step_Feed_CapsuleCRM extends Gravity_Flow_Step_Feed_Add_On {
/**
* The step type.
*
* @var string
*/
public $_step_type = 'capsulecrm';
/**
* The name of the class used by the add-on.
*
* @var string
*/
protected $_class_name = 'GFCapsuleCRM';
/**
* Returns the step label.
*
* @return string
*/
public function get_label() {
return 'Capsule CRM';
}
/**
* Returns the feed name.
*
* @param array $feed The Capsule CRM feed properties.
*
* @return string
*/
public function get_feed_label( $feed ) {
$label = $feed['meta']['feed_name'];
return $label;
}
}
Gravity_Flow_Steps::register( new Gravity_Flow_Step_Feed_CapsuleCRM() );

View File

@@ -0,0 +1,58 @@
<?php
/**
* Gravity Flow Step Feed CleverReach
*
* @package GravityFlow
* @subpackage Classes/Gravity_Flow_Step_Feed_CleverReach
* @copyright Copyright (c) 2016-2018, Steven Henty S.L.
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
* @since 1.3.1.6
*/
if ( ! class_exists( 'GFForms' ) ) {
die();
}
/**
* Class Gravity_Flow_Step_Feed_CleverReach
*/
class Gravity_Flow_Step_Feed_CleverReach extends Gravity_Flow_Step_Feed_Add_On {
/**
* The step type.
*
* @var string
*/
public $_step_type = 'cleverreach';
/**
* The name of the class used by the add-on.
*
* @var string
*/
protected $_class_name = 'GFCleverReach';
/**
* Returns the step label.
*
* @return string
*/
public function get_label() {
return 'CleverReach';
}
/**
* Returns the feed name.
*
* @param array $feed The CleverReach feed properties.
*
* @return string
*/
public function get_feed_label( $feed ) {
$label = $feed['meta']['feed_name'];
return $label;
}
}
Gravity_Flow_Steps::register( new Gravity_Flow_Step_Feed_CleverReach() );

View File

@@ -0,0 +1,66 @@
<?php
/**
* Gravity Flow Step Feed Constant Contact
*
* @package GravityFlow
* @subpackage Classes/Gravity_Flow_Step_Feed_Constant_Contact
* @copyright Copyright (c) 2017, Steven Henty S.L.
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
* @since 1.5.1-dev
*/
if ( ! class_exists( 'GFForms' ) ) {
die();
}
/**
* Class Gravity_Flow_Step_Feed_Constant_Contact
*/
class Gravity_Flow_Step_Feed_Constant_Contact extends Gravity_Flow_Step_Feed_Add_On {
/**
* The step type.
*
* @var string
*/
public $_step_type = 'constant_contact';
/**
* The name of the class used by the add-on.
*
* @var string
*/
protected $_class_name = 'GF_Constant_Contact';
/**
* The slug used by the add-on.
*
* @var string
*/
protected $_slug = 'gravity-forms-constant-contact';
/**
* Returns the step label.
*
* @return string
*/
public function get_label() {
return 'Constant Contact';
}
/**
* Returns the feed name.
*
* @param array $feed The Constant Contact feed properties.
*
* @return string
*/
public function get_feed_label( $feed ) {
$label = $feed['meta']['feed_name'];
return $label;
}
}
Gravity_Flow_Steps::register( new Gravity_Flow_Step_Feed_Constant_Contact() );

View File

@@ -0,0 +1,74 @@
<?php
/**
* Gravity Flow Step Feed ConvertKit
*
* @package GravityFlow
* @subpackage Classes/Gravity_Flow_Step_Feed_ConvertKit
* @copyright Copyright (c) 2016-2018, Steven Henty S.L.
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
* @since 1.3.3-dev
*/
if ( ! class_exists( 'GFForms' ) ) {
die();
}
/**
* Class Gravity_Flow_Step_Feed_ConvertKit
*/
class Gravity_Flow_Step_Feed_ConvertKit extends Gravity_Flow_Step_Feed_Add_On {
/**
* The step type.
*
* @var string
*/
public $_step_type = 'convertkit';
/**
* The name of the class used by the add-on.
*
* @var string
*/
protected $_class_name = 'GFConvertKit';
/**
* The slug used by the add-on.
*
* @var string
*/
protected $_slug = 'ckgf';
/**
* Returns the step label.
*
* @return string
*/
public function get_label() {
return 'ConvertKit';
}
/**
* Returns the feed name.
*
* @param array $feed The ConvertKit feed properties.
*
* @return string
*/
public function get_feed_label( $feed ) {
$label = $feed['meta']['feed_name'];
return $label;
}
/**
* Returns the URL for the step icon.
*
* @return string
*/
public function get_icon_url() {
return $this->get_base_url() . '/images/convertkit-icon.png';
}
}
Gravity_Flow_Steps::register( new Gravity_Flow_Step_Feed_ConvertKit() );

View File

@@ -0,0 +1,110 @@
<?php
/**
* Gravity Flow Step Feed Drip
*
* @package GravityFlow
* @subpackage Classes/Gravity_Flow_Step_Feed_Drip
* @copyright Copyright (c) 2016-2018, Steven Henty S.L.
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
* @since 1.3.3-dev
*/
if ( ! class_exists( 'GFForms' ) ) {
die();
}
/**
* Class Gravity_Flow_Step_Feed_Drip
*/
class Gravity_Flow_Step_Feed_Drip extends Gravity_Flow_Step_Feed_Add_On {
/**
* The step type.
*
* @var string
*/
public $_step_type = 'drip';
/**
* The name of the class used by the add-on.
*
* @var string
*/
protected $_class_name = 'GFP_Drip';
/**
* The current instance of the Drip add-on or null.
*
* @var null|GFP_Drip_Addon
*/
protected $_addon_instance = null;
/**
* Returns the step label.
*
* @return string
*/
public function get_label() {
return 'Drip';
}
/**
* Returns the URL for the step icon.
*
* @return string
*/
public function get_icon_url() {
return $this->get_base_url() . '/images/drip-icon.svg';
}
/**
* Returns the Drip add-on feeds for the current form.
*
* @return array
*/
public function get_feeds() {
if ( is_object( $this->get_add_on_instance() ) ) {
$form_id = $this->get_form_id();
$feeds = $this->get_add_on_instance()->get_feeds( $form_id );
} else {
$feeds = array();
}
return $feeds;
}
/**
* Processes the given feed for the add-on.
*
* @param array $feed The Drip add-on feed properties.
*
* @return bool Is feed processing complete?
*/
public function process_feed( $feed ) {
if ( is_object( $this->get_add_on_instance() ) ) {
$form = $this->get_form();
$entry = $this->get_entry();
$this->get_add_on_instance()->process_feed( $feed, $entry, $form );
}
return true;
}
/**
* Returns the current instance of the Drip add-on.
*
* @return GFP_Drip_Addon|null
*/
public function get_add_on_instance() {
if ( ! is_object( $this->_add_on_instance ) && class_exists( $this->_class_name ) ) {
$add_on = new GFP_Drip();
$add_on->plugins_loaded();
$this->_add_on_instance = $add_on->get_addon_object();
}
return $this->_add_on_instance;
}
}
Gravity_Flow_Steps::register( new Gravity_Flow_Step_Feed_Drip() );

View File

@@ -0,0 +1,110 @@
<?php
/**
* Gravity Flow Step Feed Dropbox
*
* @package GravityFlow
* @subpackage Classes/Gravity_Flow_Step_Feed_Dropbox
* @copyright Copyright (c) 2016-2018, Steven Henty S.L.
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
* @since 1.3.3-dev
*/
if ( ! class_exists( 'GFForms' ) ) {
die();
}
/**
* Class Gravity_Flow_Step_Feed_Dropbox
*/
class Gravity_Flow_Step_Feed_Dropbox extends Gravity_Flow_Step_Feed_Add_On {
/**
* The step type.
*
* @var string
*/
public $_step_type = 'dropbox';
/**
* The name of the class used by the add-on.
*
* @var string
*/
protected $_class_name = 'GF_Dropbox';
/**
* Returns the step label.
*
* @return string
*/
public function get_label() {
return 'Dropbox';
}
/**
* Returns the URL for the step icon.
*
* @return string
*/
public function get_icon_url() {
return $this->get_base_url() . '/images/dropbox-icon.svg';
}
/**
* Returns the class name for the add-on.
*
* @return string
*/
public function get_feed_add_on_class_name() {
if ( class_exists( 'GFDropbox' ) ) {
$this->_class_name = 'GFDropbox';
}
return $this->_class_name;
}
/**
* Process the feed; remove the feed from the processed feeds list;
*
* @param array $feed The feed to be processed.
*
* @return bool Returning false to ensure the next step is not processed until after the files are uploaded.
*/
public function process_feed( $feed ) {
$feed['meta']['workflow_step'] = $this->get_id();
parent::process_feed( $feed );
return false;
}
}
Gravity_Flow_Steps::register( new Gravity_Flow_Step_Feed_Dropbox() );
/**
* If the feed for a Dropbox step was processed maybe resume the workflow.
*
* @param array $feed The Dropbox feed for which uploading has just completed.
* @param array $entry The entry which was processed.
* @param array $form The form object for this entry.
*/
function gravity_flow_step_dropbox_post_upload( $feed, $entry, $form ) {
$workflow_is_pending = rgar( $entry, 'workflow_final_status' ) == 'pending';
$feed_step_id = rgar( $feed['meta'], 'workflow_step' );
$entry_step_id = rgar( $entry, 'workflow_step' );
if ( $workflow_is_pending && ! empty( $feed_step_id ) && $feed_step_id == $entry_step_id ) {
$step = Gravity_Flow_Steps::get( 'dropbox' );
if ( $step ) {
$add_on_feeds = $step->get_processed_add_on_feeds( $entry['id'] );
if ( ! in_array( $feed['id'], $add_on_feeds ) ) {
$add_on_feeds[] = $feed['id'];
$step->update_processed_feeds( $add_on_feeds, $entry['id'] );
gravity_flow()->process_workflow( $form, $entry['id'] );
}
}
}
}
add_action( 'gform_dropbox_post_upload', 'gravity_flow_step_dropbox_post_upload', 10, 3 );

View File

@@ -0,0 +1,58 @@
<?php
/**
* Gravity Flow Step Feed Emma
*
* @package GravityFlow
* @subpackage Classes/Gravity_Flow_Step_Feed_Emma
* @copyright Copyright (c) 2016-2018, Steven Henty S.L.
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
* @since 1.0
*/
if ( ! class_exists( 'GFForms' ) ) {
die();
}
/**
* Class Gravity_Flow_Step_Feed_Emma
*/
class Gravity_Flow_Step_Feed_Emma extends Gravity_Flow_Step_Feed_Add_On {
/**
* The step type.
*
* @var string
*/
public $_step_type = 'emma';
/**
* The name of the class used by the add-on.
*
* @var string
*/
protected $_class_name = 'GFEmma';
/**
* Returns the step label.
*
* @return string
*/
public function get_label() {
return 'Emma';
}
/**
* Returns the feed name.
*
* @param array $feed The Emma feed properties.
*
* @return string
*/
public function get_feed_label( $feed ) {
$label = $feed['meta']['feed_name'];
return $label;
}
}
Gravity_Flow_Steps::register( new Gravity_Flow_Step_Feed_Emma() );

View File

@@ -0,0 +1,46 @@
<?php
/**
* Gravity Flow Step Feed FreshBooks
*
* @package GravityFlow
* @subpackage Classes/Gravity_Flow_Step_Feed_FreshBooks
* @copyright Copyright (c) 2016-2018, Steven Henty S.L.
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
* @since 1.3.1.6
*/
if ( ! class_exists( 'GFForms' ) ) {
die();
}
/**
* Class Gravity_Flow_Step_Feed_FreshBooks
*/
class Gravity_Flow_Step_Feed_FreshBooks extends Gravity_Flow_Step_Feed_Add_On {
/**
* The step type.
*
* @var string
*/
public $_step_type = 'freshbooks';
/**
* The name of the class used by the add-on.
*
* @var string
*/
protected $_class_name = 'GFFreshBooks';
/**
* Returns the step label.
*
* @return string
*/
public function get_label() {
return 'FreshBooks';
}
}
Gravity_Flow_Steps::register( new Gravity_Flow_Step_Feed_FreshBooks() );

View File

@@ -0,0 +1,58 @@
<?php
/**
* Gravity Flow Step Feed GetResponse
*
* @package GravityFlow
* @subpackage Classes/Gravity_Flow_Step_Feed_GetResponse
* @copyright Copyright (c) 2016-2018, Steven Henty S.L.
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
* @since 1.3.1.6
*/
if ( ! class_exists( 'GFForms' ) ) {
die();
}
/**
* Class Gravity_Flow_Step_Feed_GetResponse
*/
class Gravity_Flow_Step_Feed_GetResponse extends Gravity_Flow_Step_Feed_Add_On {
/**
* The step type.
*
* @var string
*/
public $_step_type = 'getresponse';
/**
* The name of the class used by the add-on.
*
* @var string
*/
protected $_class_name = 'GFGetResponse';
/**
* Returns the step label.
*
* @return string
*/
public function get_label() {
return 'GetResponse';
}
/**
* Returns the feed name.
*
* @param array $feed The GetResponse feed properties.
*
* @return string
*/
public function get_feed_label( $feed ) {
$label = $feed['meta']['feed_name'];
return $label;
}
}
Gravity_Flow_Steps::register( new Gravity_Flow_Step_Feed_GetResponse() );

View File

@@ -0,0 +1,67 @@
<?php
/**
* Gravity Flow Step Feed Help Scout
*
* @package GravityFlow
* @subpackage Classes/Gravity_Flow_Step_Feed_HelpScout
* @copyright Copyright (c) 2016-2018, Steven Henty S.L.
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
* @since 1.3.2-dev
*/
if ( ! class_exists( 'GFForms' ) ) {
die();
}
/**
* Class Gravity_Flow_Step_Feed_HelpScout
*/
class Gravity_Flow_Step_Feed_HelpScout extends Gravity_Flow_Step_Feed_Add_On {
/**
* The step type.
*
* @var string
*/
public $_step_type = 'helpscout';
/**
* The name of the class used by the add-on.
*
* @var string
*/
protected $_class_name = 'GFHelpScout';
/**
* Returns the step label.
*
* @return string
*/
public function get_label() {
return 'Help Scout';
}
/**
* Returns the feed name.
*
* @param array $feed The Help Scout feed properties.
*
* @return string
*/
public function get_feed_label( $feed ) {
$label = $feed['meta']['feed_name'];
return $label;
}
/**
* Returns the URL for the step icon.
*
* @return string
*/
public function get_icon_url() {
return $this->get_base_url() . '/images/helpscout-icon.png';
}
}
Gravity_Flow_Steps::register( new Gravity_Flow_Step_Feed_HelpScout() );

View File

@@ -0,0 +1,58 @@
<?php
/**
* Gravity Flow Step Feed Highrise
*
* @package GravityFlow
* @subpackage Classes/Gravity_Flow_Step_Feed_Highrise
* @copyright Copyright (c) 2016-2018, Steven Henty S.L.
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
* @since 1.3.2-dev
*/
if ( ! class_exists( 'GFForms' ) ) {
die();
}
/**
* Class Gravity_Flow_Step_Feed_Highrise
*/
class Gravity_Flow_Step_Feed_Highrise extends Gravity_Flow_Step_Feed_Add_On {
/**
* The step type.
*
* @var string
*/
public $_step_type = 'highrise';
/**
* The name of the class used by the add-on.
*
* @var string
*/
protected $_class_name = 'GFHighrise';
/**
* Returns the step label.
*
* @return string
*/
public function get_label() {
return 'Highrise';
}
/**
* Returns the feed name.
*
* @param array $feed The Highrise feed properties.
*
* @return string
*/
public function get_feed_label( $feed ) {
$label = $feed['meta']['feed_name'];
return $label;
}
}
Gravity_Flow_Steps::register( new Gravity_Flow_Step_Feed_Highrise() );

View File

@@ -0,0 +1,67 @@
<?php
/**
* Gravity Flow Step Feed HipChat
*
* @package GravityFlow
* @subpackage Classes/Gravity_Flow_Step_Feed_HipChat
* @copyright Copyright (c) 2016-2018, Steven Henty S.L.
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
* @since 1.3.2-dev
*/
if ( ! class_exists( 'GFForms' ) ) {
die();
}
/**
* Class Gravity_Flow_Step_Feed_HipChat
*/
class Gravity_Flow_Step_Feed_HipChat extends Gravity_Flow_Step_Feed_Add_On {
/**
* The step type.
*
* @var string
*/
public $_step_type = 'hipchat';
/**
* The name of the class used by the add-on.
*
* @var string
*/
protected $_class_name = 'GFHipChat';
/**
* Returns the step label.
*
* @return string
*/
public function get_label() {
return 'HipChat';
}
/**
* Returns the feed name.
*
* @param array $feed The HipChat feed properties.
*
* @return string
*/
public function get_feed_label( $feed ) {
$label = $feed['meta']['feed_name'];
return $label;
}
/**
* Returns the URL for the step icon.
*
* @return string
*/
public function get_icon_url() {
return $this->get_base_url() . '/images/hipchat-icon.svg';
}
}
Gravity_Flow_Steps::register( new Gravity_Flow_Step_Feed_HipChat() );

View File

@@ -0,0 +1,66 @@
<?php
/**
* Gravity Flow Step Feed HubSpot
*
* @package GravityFlow
* @subpackage Classes/Gravity_Flow_Step_Feed_HubSpot
* @copyright Copyright (c) 2016-2018, Steven Henty S.L.
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
* @since 1.3.3-dev
*/
if ( ! class_exists( 'GFForms' ) ) {
die();
}
/**
* Class Gravity_Flow_Step_Feed_HubSpot
*/
class Gravity_Flow_Step_Feed_HubSpot extends Gravity_Flow_Step_Feed_Add_On {
/**
* The step type.
*
* @var string
*/
public $_step_type = 'hubspot';
/**
* The name of the class used by the add-on.
*
* @var string
*/
protected $_class_name = '\BigSea\GFHubSpot\GF_HubSpot';
/**
* The slug used by the add-on.
*
* @var string
*/
protected $_slug = 'gravityforms-hubspot';
/**
* Returns the step label.
*
* @return string
*/
public function get_label() {
return 'HubSpot';
}
/**
* Returns the class name for the add-on.
*
* @return string
*/
public function get_feed_add_on_class_name() {
if ( ! class_exists( '\BigSea\GFHubSpot\GF_HubSpot' ) ) {
$this->_class_name = 'GF_HubSpot';
}
return $this->_class_name;
}
}
Gravity_Flow_Steps::register( new Gravity_Flow_Step_Feed_HubSpot() );

View File

@@ -0,0 +1,58 @@
<?php
/**
* Gravity Flow Step Feed iContact
*
* @package GravityFlow
* @subpackage Classes/Gravity_Flow_Step_Feed_iContact
* @copyright Copyright (c) 2015-2018, Steven Henty S.L.
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
* @since 1.3.2-dev
*/
if ( ! class_exists( 'GFForms' ) ) {
die();
}
/**
* Class Gravity_Flow_Step_Feed_iContact
*/
class Gravity_Flow_Step_Feed_iContact extends Gravity_Flow_Step_Feed_Add_On {
/**
* The step type.
*
* @var string
*/
public $_step_type = 'icontact';
/**
* The name of the class used by the add-on.
*
* @var string
*/
protected $_class_name = 'GFiContact';
/**
* Returns the step label.
*
* @return string
*/
public function get_label() {
return 'iContact';
}
/**
* Returns the feed name.
*
* @param array $feed The iContact feed properties.
*
* @return string
*/
public function get_feed_label( $feed ) {
$label = $feed['meta']['feed_name'];
return $label;
}
}
Gravity_Flow_Steps::register( new Gravity_Flow_Step_Feed_iContact() );

View File

@@ -0,0 +1,58 @@
<?php
/**
* Gravity Flow Step Feed Mad Mimi
*
* @package GravityFlow
* @subpackage Classes/Gravity_Flow_Step_Feed_MadMimi
* @copyright Copyright (c) 2015-2018, Steven Henty S.L.
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
* @since 1.3.2-dev
*/
if ( ! class_exists( 'GFForms' ) ) {
die();
}
/**
* Class Gravity_Flow_Step_Feed_MadMimi
*/
class Gravity_Flow_Step_Feed_MadMimi extends Gravity_Flow_Step_Feed_Add_On {
/**
* The step type.
*
* @var string
*/
public $_step_type = 'madmimi';
/**
* The name of the class used by the add-on.
*
* @var string
*/
protected $_class_name = 'GFMadMimi';
/**
* Returns the step label.
*
* @return string
*/
public function get_label() {
return 'Mad Mimi';
}
/**
* Returns the feed name.
*
* @param array $feed The Mad Mimi feed properties.
*
* @return string
*/
public function get_feed_label( $feed ) {
$label = $feed['meta']['feed_name'];
return $label;
}
}
Gravity_Flow_Steps::register( new Gravity_Flow_Step_Feed_MadMimi() );

View File

@@ -0,0 +1,55 @@
<?php
/**
* Gravity Flow Step Feed MailChimp
*
* @package GravityFlow
* @subpackage Classes/Gravity_Flow_Step_Feed_MailChimp
* @copyright Copyright (c) 2015-2018, Steven Henty S.L.
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
* @since 1.0
*/
if ( ! class_exists( 'GFForms' ) ) {
die();
}
/**
* Class Gravity_Flow_Step_Feed_MailChimp
*/
class Gravity_Flow_Step_Feed_MailChimp extends Gravity_Flow_Step_Feed_Add_On {
/**
* The step type.
*
* @var string
*/
public $_step_type = 'mailchimp';
/**
* The name of the class used by the add-on.
*
* @var string
*/
protected $_class_name = 'GFMailChimp';
/**
* Returns the step label.
*
* @return string
*/
public function get_label() {
return 'MailChimp';
}
/**
* Returns the URL for the step icon.
*
* @return string
*/
public function get_icon_url() {
return $this->get_base_url() . '/images/mailchimp.svg';
}
}
Gravity_Flow_Steps::register( new Gravity_Flow_Step_Feed_MailChimp() );

View File

@@ -0,0 +1,74 @@
<?php
/**
* Gravity Flow Step Feed Pipedrive
*
* @package GravityFlow
* @subpackage Classes/Gravity_Flow_Step_Feed_Pipedrive
* @copyright Copyright (c) 2016-2018, Steven Henty S.L.
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
* @since 1.5.1-dev
*/
if ( ! class_exists( 'GFForms' ) ) {
die();
}
/**
* Class Gravity_Flow_Step_Feed_Pipedrive
*/
class Gravity_Flow_Step_Feed_Pipedrive extends Gravity_Flow_Step_Feed_Add_On {
/**
* The step type.
*
* @var string
*/
public $_step_type = 'pipedrive';
/**
* The name of the class used by the add-on.
*
* @var string
*/
protected $_class_name = 'WPGravityFormsToPipeDriveCRM';
/**
* The slug used by the add-on.
*
* @var string
*/
protected $_slug = 'gf2pdcrm';
/**
* The current instance of the Pipedrive add-on or null.
*
* @var null|WPGravityFormsToPipedriveAddOn
*/
protected $_addon_instance = null;
/**
* Returns the step label.
*
* @return string
*/
public function get_label() {
return 'Pipedrive';
}
/**
* Retrieve an instance of the add-on associated with this step.
*
* @return WPGravityFormsToPipedriveAddOn|null
*/
public function get_add_on_instance() {
if ( ! is_object( $this->_add_on_instance ) ) {
$add_on = new WPGravityFormsToPipeDriveCRM();
$add_on->wpgf2pdcrm_load_addon();
$this->_add_on_instance = $add_on->_wpgf2pdcrm_addon_OBJECT;
}
return $this->_add_on_instance;
}
}
Gravity_Flow_Steps::register( new Gravity_Flow_Step_Feed_Pipedrive() );

View File

@@ -0,0 +1,45 @@
<?php
/**
* Gravity Flow Step Feed Post Creation
*
* @package GravityFlow
* @subpackage Classes/Gravity_Flow_Step_Feed_Breeze
* @copyright Copyright (c) 2016-2018, Steven Henty S.L.
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
* @since 1.4.3-dev
*/
if ( ! class_exists( 'GFForms' ) ) {
die();
}
/**
* Class Gravity_Flow_Step_Feed_Post_Creation
*/
class Gravity_Flow_Step_Feed_Post_Creation extends Gravity_Flow_Step_Feed_Add_On {
/**
* The step type.
*
* @var string
*/
public $_step_type = 'post_creation';
/**
* The name of the class used by the add-on.
*
* @var string
*/
protected $_class_name = 'GF_Post_Creation';
/**
* Returns the step label.
*
* @return string
*/
public function get_label() {
return 'Post Creation';
}
}
Gravity_Flow_Steps::register( new Gravity_Flow_Step_Feed_Post_Creation() );

View File

@@ -0,0 +1,140 @@
<?php
/**
* Gravity Flow Step Feed SendinBlue
*
* @package GravityFlow
* @subpackage Classes/Gravity_Flow_Step_Feed_Sendinblue
* @copyright Copyright (c) 2017, Steven Henty S.L.
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
* @since 1.5.1-dev
*/
if ( ! class_exists( 'GFForms' ) ) {
die();
}
/**
* Class Gravity_Flow_Step_Feed_Sendinblue
*/
class Gravity_Flow_Step_Feed_Sendinblue extends Gravity_Flow_Step_Feed_Add_On {
/**
* The step type.
*
* @var string
*/
public $_step_type = 'sendinblue';
/**
* The name of the class used by the add-on.
*
* @var string
*/
protected $_class_name = 'GFSIB_Manager';
/**
* The slug used by the add-on.
*
* @var string
*/
protected $_slug = 'gravityformssendinblue';
/**
* Returns the step label.
*
* @return string
*/
public function get_label() {
return 'SendinBlue';
}
/**
* Returns the URL for the step icon.
*
* @return string
*/
public function get_icon_url() {
return $this->get_base_url() . '/images/sendinblue-icon.png';
}
/**
* Returns the SendinBlue add-on feeds for the current form.
*
* @return array
*/
public function get_feeds() {
if ( class_exists( 'GFSendinBlueData' ) ) {
$form_id = $this->get_form_id();
$feeds = GFSendinBlueData::get_feed_by_form( $form_id, true );
} else {
$feeds = array();
}
return $feeds;
}
/**
* Processes the given feed for the add-on.
*
* @param array $feed The SendinBlue add-on feed properties.
*
* @return bool Is feed processing complete?
*/
public function process_feed( $feed ) {
$form = $this->get_form();
$entry = $this->get_entry();
GFSIB_Manager::export_feed( $entry, $form, $feed );
return true;
}
/**
* Prevent the feeds assigned to the current step from being processed by the associated add-on.
*/
public function intercept_submission() {
remove_action( 'gform_post_submission', array( 'GFSIB_Manager', 'export' ) );
}
/**
* Returns the feed name.
*
* @param array $feed The SendinBlue feed properties.
*
* @return string
*/
public function get_feed_label( $feed ) {
return $feed['meta']['contact_list_name'];
}
/**
* Determines if the supplied feed should be processed.
*
* @param array $feed The current feed.
* @param array $form The current form.
* @param array $entry The current entry.
*
* @return bool
*/
public function is_feed_condition_met( $feed, $form, $entry ) {
if ( ! rgars( $feed, 'meta/optin_enabled' ) ) {
return true;
}
$feed['meta']['feed_condition_conditional_logic'] = true;
$feed['meta']['feed_condition_conditional_logic_object']['conditionalLogic'] = array(
'logicType' => 'all',
'rules' => array(
array(
'fieldId' => rgars( $feed, 'meta/optin_field_id' ),
'operator' => rgars( $feed, 'meta/optin_operator' ),
'value' => rgars( $feed, 'meta/optin_value' ),
),
),
);
return parent::is_feed_condition_met( $feed, $form, $entry );
}
}
Gravity_Flow_Steps::register( new Gravity_Flow_Step_Feed_Sendinblue() );

View File

@@ -0,0 +1,67 @@
<?php
/**
* Gravity Flow Step Feed Slack
*
* @package GravityFlow
* @subpackage Classes/Gravity_Flow_Step_Feed_Slack
* @copyright Copyright (c) 2016-2018, Steven Henty S.L.
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
* @since 1.3.2-dev
*/
if ( ! class_exists( 'GFForms' ) ) {
die();
}
/**
* Class Gravity_Flow_Step_Feed_Slack
*/
class Gravity_Flow_Step_Feed_Slack extends Gravity_Flow_Step_Feed_Add_On {
/**
* The step type.
*
* @var string
*/
public $_step_type = 'slack';
/**
* The name of the class used by the add-on.
*
* @var string
*/
protected $_class_name = 'GFSlack';
/**
* Returns the step label.
*
* @return string
*/
public function get_label() {
return 'Slack';
}
/**
* Returns the feed name.
*
* @param array $feed The Slack feed properties.
*
* @return string
*/
public function get_feed_label( $feed ) {
$label = $feed['meta']['feed_name'];
return $label;
}
/**
* Returns the URL for the step icon.
*
* @return string
*/
public function get_icon_url() {
return $this->get_base_url() . '/images/slack-icon.png';
}
}
Gravity_Flow_Steps::register( new Gravity_Flow_Step_Feed_Slack() );

View File

@@ -0,0 +1,324 @@
<?php
/**
* Gravity Flow Step Feed Sliced Invoices
*
* @package GravityFlow
* @subpackage Classes/Gravity_Flow_Step_Feed_Sliced_Invoices
* @copyright Copyright (c) 2016-2018, Steven Henty S.L.
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
* @since 1.3.3-dev
*/
if ( ! class_exists( 'GFForms' ) ) {
die();
}
/**
* Class Gravity_Flow_Step_Feed_Sliced_Invoices
*/
class Gravity_Flow_Step_Feed_Sliced_Invoices extends Gravity_Flow_Step_Feed_Add_On {
/**
* The step type.
*
* @var string
*/
public $_step_type = 'slicedinvoices';
/**
* The name of the class used by the add-on.
*
* @var string
*/
protected $_class_name = 'Sliced_Invoices_GF';
/**
* The slug used by the add-on.
*
* @var string
*/
protected $_slug = 'slicedinvoices';
/**
* Enable the expiration settings.
*
* @since 1.6.1-dev-2
*
* @return bool
*/
public function supports_expiration() {
return true;
}
/**
* Returns the step label.
*
* @return string
*/
public function get_label() {
return 'Sliced Invoices';
}
/**
* Returns the URL for the step icon.
*
* @return string
*/
public function get_icon_url() {
return $this->get_base_url() . '/images/sliced-invoices-icon.svg';
}
/**
* Returns the settings for this step.
*
* @since 1.6.1-dev-2 Added the Step Completion setting.
*
* @return array
*/
public function get_settings() {
$settings = parent::get_settings();
if ( ! $this->is_supported() ) {
return $settings;
}
$settings_api = $this->get_common_settings_api();
$fields = array(
$settings_api->get_setting_assignee_type(),
$settings_api->get_setting_assignees(),
$settings_api->get_setting_assignee_routing(),
$settings_api->get_setting_notification_tabs( array(
array(
'label' => __( 'Assignee Email', 'gravityflow' ),
'id' => 'tab_assignee_notification',
'fields' => $settings_api->get_setting_notification( array(
'type' => 'assignee',
) ),
)
) ),
$settings_api->get_setting_instructions(),
$settings_api->get_setting_display_fields(),
array(
'name' => 'post_feed_completion',
'type' => 'select',
'label' => __( 'Step Completion', 'gravityflow' ),
'choices' => array(
array( 'label' => __( 'Immediately following feed processing', 'gravityflow' ), 'value' => '' ),
array( 'label' => __( 'Delay until invoices are paid', 'gravityflow' ), 'value' => 'delayed' ),
),
)
);
$settings['fields'] = array_merge( $settings['fields'], $fields );
return $settings;
}
/**
* Processes this step.
*
* @since 1.6.1-dev-2
*
* @return bool Is the step complete?
*/
public function process() {
$complete = parent::process();
$this->assign();
return $complete;
}
/**
* Processes the given feed for the add-on.
*
* @since 1.6.1-dev-2
*
* @param array $feed The feed to be processed.
*
* @return bool Returning false if the feed created an invoice to ensure the next step is not processed until after the invoice is paid.
*/
public function process_feed( $feed ) {
add_action( 'sliced_gravityforms_feed_processed', array( $this, 'sliced_gravityforms_feed_processed' ), 1, 3 );
parent::process_feed( $feed );
remove_action( 'sliced_gravityforms_feed_processed', array( $this, 'sliced_gravityforms_feed_processed' ), 1 );
return rgars( $feed, 'meta/post_type' ) !== 'invoice' || $this->post_feed_completion !== 'delayed' ? true : false;
}
/**
* Perform any actions once the invoice/quote has been created.
*
* @since 1.6.1-dev-2
*
* @param int $id The invoice (post) ID.
* @param array $feed The feed which created the invoice.
* @param array $entry The entry which created the invoice.
*/
public function sliced_gravityforms_feed_processed( $id, $feed, $entry ) {
if ( rgars( $feed, 'meta/post_type' ) === 'invoice' && $this->post_feed_completion === 'delayed' ) {
// Store the IDs so we can complete the step once the invoice is paid.
update_post_meta( $id, '_gform-entry-id', rgar( $entry, 'id' ) );
update_post_meta( $id, '_gform-feed-id', rgar( $feed, 'id' ) );
update_post_meta( $id, '_gravityflow-step-id', $this->get_id() );
if ( function_exists( 'sliced_get_accepted_payment_methods' ) ) {
update_post_meta( $id, '_sliced_payment_methods', array_keys( sliced_get_accepted_payment_methods() ) );
}
}
}
/**
* Display the workflow detail box for this step.
*
* @since 1.6.1-dev-2
*
* @param array $form The current form.
* @param array $args The page arguments.
*/
public function workflow_detail_box( $form, $args ) {
$args = array(
'post_type' => 'sliced_invoice',
'meta_query' => array(
array(
'key' => '_gform-entry-id',
'value' => $this->get_entry_id(),
),
array(
'key' => '_gravityflow-step-id',
'value' => $this->get_id(),
),
),
);
$invoices = get_posts( $args );
if ( ! empty( $invoices ) ) {
echo sprintf( '<h4 style="margin-bottom:10px;">%s</h4>', $this->get_label() );
$assignee_key = gravity_flow()->get_current_user_assignee_key();
$can_edit = $this->is_assignee( $assignee_key ) && current_user_can( 'edit_posts' );
/* @var WP_Post $invoice */
foreach ( $invoices as $invoice ) {
$title = $invoice->post_title;
if ( ! $title ) {
$feed_id = get_post_meta( $invoice->ID, '_gform-feed-id', true );
$feed = gravity_flow()->get_feed( $feed_id );
$title = rgar( $feed['meta'], 'feedName' );
}
echo sprintf( '%s: %s<br><br>', esc_html__( 'Title', 'gravityflow' ), esc_html( $title ) );
echo sprintf( '%s: %s<br><br>', esc_html__( 'Number', 'gravityflow' ), esc_html( get_post_meta( $invoice->ID, '_sliced_invoice_number', true ) ) );
if ( function_exists( 'sliced_get_invoice_total' ) ) {
echo sprintf( '%s: %s<br><br>', esc_html__( 'Total', 'gravityflow' ), esc_html( sliced_get_invoice_total( $invoice->ID ) ) );
}
if ( class_exists( 'Sliced_Shared' ) ) {
$sent_status = '';
if ( class_exists( 'Sliced_Invoice' ) && Sliced_Invoice::get_email_sent_date( $invoice->ID ) ) {
$sent_status = '&nbsp;&ndash;&nbsp;' . esc_html__( 'Invoice Sent', 'gravityflow' );
}
echo sprintf( '%s: %s%s<br><br>', esc_html__( 'Status', 'gravityflow' ), esc_html( Sliced_Shared::get_status( $invoice->ID, 'invoice' ) ), $sent_status );
}
echo '<div class="gravityflow-action-buttons">';
if ( $can_edit ) {
echo sprintf( '<a href="%s" target="_blank" class="button button-large button-primary">%s</a> ', get_edit_post_link( $invoice->ID ), esc_html__( 'Edit', 'gravityflow' ) );
}
echo sprintf( '<a href="%s" target="_blank" class="button button-large button-primary">%s</a><br><br>', get_permalink( $invoice ), esc_html__( 'Preview', 'gravityflow' ) );
echo '</div>';
}
}
}
/**
* When restarting the workflow or step delete the step ID from the post meta of the invoices which already exist.
*
* @since 1.6.1-dev-2
*/
public function restart_action() {
$args = array(
'post_type' => 'sliced_invoice',
'meta_query' => array(
array(
'key' => '_gform-entry-id',
'value' => $this->get_entry_id(),
),
array(
'key' => '_gravityflow-step-id',
'value' => $this->get_id(),
),
),
);
$invoices = get_posts( $args );
if ( empty( $invoices ) ) {
return;
}
/* @var WP_Post $invoice */
foreach ( $invoices as $invoice ) {
delete_post_meta( $invoice->ID, '_gravityflow-step-id' );
}
}
/**
* Resume the workflow if the invoice is paid and originated from a feed processed by one of our steps.
*
* @since 1.6.1-dev-2
*
* @param string $id The invoice (post) ID.
* @param string $status The invoice status.
*/
public static function invoice_status_update( $id, $status ) {
if ( $status !== 'paid' ) {
return;
}
$entry_id = get_post_meta( $id, '_gform-entry-id', true );
$feed_id = get_post_meta( $id, '_gform-feed-id', true );
$step_id = get_post_meta( $id, '_gravityflow-step-id', true );
if ( ! $entry_id || ! $feed_id || ! $step_id ) {
return;
}
$entry = GFAPI::get_entry( $entry_id );
if ( ! is_wp_error( $entry ) && rgar( $entry, 'workflow_final_status' ) === 'pending' ) {
$api = new Gravity_Flow_API( $entry['form_id'] );
/* @var Gravity_Flow_Step_Feed_Sliced_Invoices $step */
$step = $api->get_current_step( $entry );
if ( $step && $step->get_id() == $step_id ) {
$feed = gravity_flow()->get_feed( $feed_id );
$label = $step->get_feed_label( $feed );
$step->add_note( sprintf( esc_html__( 'Invoice paid: %s', 'gravityflow' ), $label ) );
$step->log_debug( __METHOD__ . '() - Feed processing complete: ' . $label );
$add_on_feeds = $step->get_processed_add_on_feeds( $entry_id );
if ( ! in_array( $feed_id, $add_on_feeds ) ) {
$add_on_feeds[] = $feed_id;
$step->update_processed_feeds( $add_on_feeds, $entry_id );
$form = GFAPI::get_form( $entry['form_id'] );
gravity_flow()->process_workflow( $form, $entry_id );
}
}
}
}
}
Gravity_Flow_Steps::register( new Gravity_Flow_Step_Feed_Sliced_Invoices() );
add_action( 'sliced_invoice_status_update', array( 'Gravity_Flow_Step_Feed_Sliced_Invoices', 'invoice_status_update' ), 10, 2 );

View File

@@ -0,0 +1,276 @@
<?php
/**
* Gravity Flow Step Feed Sprout Invoices
*
* @package GravityFlow
* @subpackage Classes/Gravity_Flow_Step_Feed_Sprout_Invoices
* @copyright Copyright (c) 2016-2018, Steven Henty S.L.
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
* @since 1.4.3-dev
*/
if ( ! class_exists( 'GFForms' ) ) {
die();
}
/**
* Class Gravity_Flow_Step_Feed_Sprout_Invoices
*/
class Gravity_Flow_Step_Feed_Sprout_Invoices extends Gravity_Flow_Step_Feed_Add_On {
/**
* The step type.
*
* @var string
*/
public $_step_type = 'sprout_invoices';
/**
* The name of the class used by the add-on.
*
* @since 2.1.2-dev
*
* @var string
*/
protected $_class_name = 'SI_GF_Integration_Addon';
/**
* The name of the slug used by the add-on.
*
* @var string
*/
protected $_slug = 'sprout-invoices-gravity-forms-integration';
/**
* The ID of the form the Form Integrations plugin is configured to work with.
*
* @var bool|int
*/
protected $_estimate_form_id = false;
/**
* The ID of the form the Invoice Submissions plugin is configured to work with.
*
* @var bool|int
*/
protected $_invoice_form_id = false;
/**
* Returns the step label.
*
* @return string
*/
public function get_label() {
return 'Sprout Invoices';
}
/**
* Returns the URL for the step icon.
*
* @return string
*/
public function get_icon_url() {
return $this->get_base_url() . '/images/sproutapps-icon.png';
}
/**
* Determines if this step type is supported.
*
* @return bool
*/
public function is_supported() {
$form_id = $this->get_form_id();
return $this->is_gf_add_on_supported() || $this->is_estimates_supported( $form_id ) || $this->is_invoices_supported( $form_id );
}
/**
* Check that the Form Integrations plugin is active and it is configured to work with the current form.
*
* @param int $form_id The ID of the current form.
*
* @return bool
*/
public function is_estimates_supported( $form_id ) {
$is_supported = class_exists( 'SI_Form_Integrations' );
if ( ! $is_supported ) {
return false;
}
if ( ! $this->_estimate_form_id ) {
$this->_estimate_form_id = get_option( SI_Form_Integrations::GRAVITY_FORM_ID );
}
return $form_id == $this->_estimate_form_id;
}
/**
* Check that the Invoice Submissions plugin is active and it is configured to work with the current form.
*
* @param int $form_id The ID of the current form.
*
* @return bool
*/
public function is_invoices_supported( $form_id ) {
$is_supported = class_exists( 'SI_IS_Gravity_Forms' );
if ( ! $is_supported ) {
return false;
}
if ( ! $this->_invoice_form_id ) {
$this->_invoice_form_id = get_option( SI_IS_Gravity_Forms::GRAVITY_FORM_ID );
}
return $form_id == $this->_invoice_form_id;
}
/**
* Checks if the feed based add-on is active.
*
* @since 2.1.2-dev
*
* @return bool
*/
public function is_gf_add_on_supported() {
return parent::is_supported();
}
/**
* Returns the label of the given feed.
*
* @since 2.1.2-dev
*
* @param array $feed The add-on feed properties.
*
* @return string
*/
public function get_feed_label( $feed ) {
$label = rgars( $feed, 'meta/feedName' );
if ( empty( $label ) ) {
switch ( $feed['meta']['si_generation'] ) {
case 'estimate':
$label = esc_html__( 'Estimate (and Client Record)', 'gravityflow' );
break;
case 'invoice':
$label = esc_html__( 'Invoice (and Client Record)', 'gravityflow' );
break;
case 'client':
$label = esc_html__( 'Client (only)', 'gravityflow' );
break;
}
}
return $label;
}
/**
* Returns the feeds for the add-on.
*
* The Form Integrations and Invoice Submissions add-ons do not extend the GF add-on framework so lets return dummy feeds for them.
*
* @since 2.1.2-dev Added support for the feed based add-on.
* @since 1.4.3-dev
*
* @return array
*/
public function get_feeds() {
$form_id = $this->get_form_id();
if ( $this->is_gf_add_on_supported() ) {
/* @var GFFeedAddOn $add_on */
$add_on = $this->get_add_on_instance();
$feeds = $add_on->get_feeds( $form_id );
} else {
$feeds = array();
}
if ( $this->is_estimates_supported( $form_id ) ) {
$feeds[] = array(
'id' => 'estimate',
'form_id' => $form_id,
'is_active' => true,
'meta' => array(
'feedName' => esc_html__( 'Create Estimate (Sprout Invoices Add-on - Form Integrations)', 'gravityflow' ),
),
'addon_slug' => $this->_step_type,
);
}
if ( $this->is_invoices_supported( $form_id ) ) {
$feeds[] = array(
'id' => 'invoice',
'form_id' => $form_id,
'is_active' => true,
'meta' => array(
'feedName' => esc_html__( 'Create Invoice (Sprout Invoices Add-on - Invoice Submissions)', 'gravityflow' ),
),
'addon_slug' => $this->_step_type,
);
}
return $feeds;
}
/**
* Processes the given feed for the add-on.
*
* @since 2.1.2-dev Added support for the feed based add-on.
* @since 1.4.3-dev
*
* @param array $feed The add-on feed properties.
*
* @return bool Is feed processing complete?
*/
public function process_feed( $feed ) {
$form = $this->get_form();
$entry = $this->get_entry();
if ( $feed['id'] == 'estimate' && $this->is_estimates_supported( $form['id'] ) ) {
SI_Form_Integrations::maybe_process_gravity_form( $entry, $form );
}
if ( $feed['id'] == 'invoice' && $this->is_invoices_supported( $form['id'] ) ) {
SI_IS_Gravity_Forms::maybe_process_gravity_form( $entry, $form );
}
if ( $this->is_gf_add_on_supported() ) {
$feed['meta']['redirect'] = false;
parent::process_feed( $feed );
}
return true;
}
/**
* Prevent the feeds assigned to the current step from being processed by the add-on.
*
* If enabled prevent the Sprout Invoices/Estimates integrations from running during submission for the current form.
*
* @since 2.1.2-dev Added support for the feed based add-on.
* @since 1.4.3-dev
*/
public function intercept_submission() {
$form_id = $this->get_form_id();
if ( $this->feed_estimate && $this->is_estimates_supported( $form_id ) ) {
remove_action( 'gform_after_submission', array( 'SI_Form_Integrations', 'maybe_process_gravity_form' ) );
}
if ( $this->feed_invoice && $this->is_invoices_supported( $form_id ) ) {
remove_action( 'gform_entry_created', array( 'SI_IS_Gravity_Forms', 'maybe_process_gravity_form' ) );
remove_filter( 'gform_confirmation_' . $form_id, array( 'SI_IS_Gravity_Forms', 'maybe_redirect_after_submission' ) );
}
if ( $this->is_gf_add_on_supported() ) {
parent::intercept_submission();
}
}
}
Gravity_Flow_Steps::register( new Gravity_Flow_Step_Feed_Sprout_Invoices() );

View File

@@ -0,0 +1,54 @@
<?php
/**
* Gravity Flow Step Feed Trello
*
* @package GravityFlow
* @subpackage Classes/Gravity_Flow_Step_Feed_Trello
* @copyright Copyright (c) 2016-2018, Steven Henty S.L.
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
* @since 1.3.2-dev
*/
if ( ! class_exists( 'GFForms' ) ) {
die();
}
/**
* Class Gravity_Flow_Step_Feed_Trello
*/
class Gravity_Flow_Step_Feed_Trello extends Gravity_Flow_Step_Feed_Add_On {
/**
* The step type.
*
* @var string
*/
public $_step_type = 'trello';
/**
* The name of the class used by the add-on.
*
* @var string
*/
protected $_class_name = 'GFTrello';
/**
* Returns the step label.
*
* @return string
*/
public function get_label() {
return 'Trello';
}
/**
* Returns the URL for the step icon.
*
* @return string
*/
public function get_icon_url() {
return $this->get_base_url() . '/images/trello-icon.svg';
}
}
Gravity_Flow_Steps::register( new Gravity_Flow_Step_Feed_Trello() );

View File

@@ -0,0 +1,54 @@
<?php
/**
* Gravity Flow Step Feed Twlio
*
* @package GravityFlow
* @subpackage Classes/Gravity_Flow_Step_Feed_Twilio
* @copyright Copyright (c) 2015-2018, Steven Henty S.L.
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
* @since 1.0
*/
if ( ! class_exists( 'GFForms' ) ) {
die();
}
/**
* Class Gravity_Flow_Step_Feed_Twilio
*/
class Gravity_Flow_Step_Feed_Twilio extends Gravity_Flow_Step_Feed_Add_On {
/**
* The step type.
*
* @var string
*/
public $_step_type = 'twilio';
/**
* The name of the class used by the add-on.
*
* @var string
*/
protected $_class_name = 'GFTwilio';
/**
* Returns the step label.
*
* @return string
*/
public function get_label() {
return 'Twilio';
}
/**
* Returns the URL for the step icon.
*
* @return string
*/
public function get_icon_url() {
return $this->get_base_url() . '/images/twilio-icon-red.svg';
}
}
Gravity_Flow_Steps::register( new Gravity_Flow_Step_Feed_Twilio() );

View File

@@ -0,0 +1,236 @@
<?php
/**
* Gravity Flow Step Feed User Registration
*
* @package GravityFlow
* @subpackage Classes/Gravity_Flow_Step_Feed_User_Registration
* @copyright Copyright (c) 2015-2018, Steven Henty S.L.
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
* @since 1.0
*/
if ( ! class_exists( 'GFForms' ) ) {
die();
}
add_action( 'gform_user_registered', array( 'Gravity_Flow_Step_Feed_User_Registration', 'action_gform_user_registered' ), 10, 3 );
/**
* Class Gravity_Flow_Step_Feed_User_Registration
*/
class Gravity_Flow_Step_Feed_User_Registration extends Gravity_Flow_Step_Feed_Add_On {
/**
* The step type.
*
* @var string
*/
public $_step_type = 'user_registration';
/**
* The name of the class used by the add-on.
*
* @var string
*/
protected $_class_name = 'GFUser';
/**
* Returns the class name for the add-on.
*
* @return string
*/
public function get_feed_add_on_class_name() {
$class_name = class_exists( 'GF_User_Registration' ) ? 'GF_User_Registration' : 'GFUser';
$this->_class_name = $class_name;
return $class_name;
}
/**
* Returns the step label.
*
* @return string
*/
public function get_label() {
return esc_html__( 'User Registration', 'gravityflow' );
}
/**
* Returns the HTML for the step icon.
*
* @return string
*/
public function get_icon_url() {
return '<i class="fa fa-user" style="color:darkgreen"></i>';
}
/**
* Returns the feeds for the add-on.
*
* @return array
*/
public function get_feeds() {
$form_id = $this->get_form_id();
if ( class_exists( 'GF_User_Registration' ) ) {
$feeds = parent::get_feeds();
} else {
$feeds = GFUserData::get_feeds( $form_id );
}
return $feeds;
}
/**
* Processes the given feed for the add-on.
*
* @param array $feed The add-on feed properties.
*
* @return bool Is feed processing complete?
*/
function process_feed( $feed ) {
if ( class_exists( 'GF_User_Registration' ) ) {
parent::process_feed( $feed );
$activation_enabled = isset( $feed['meta']['userActivationEnable'] ) && $feed['meta']['userActivationEnable'];
$step_complete = ! $activation_enabled;
return $step_complete;
}
// User Registration < 3.0.
$form = $this->get_form();
$entry = $this->get_entry();
remove_filter( 'gform_disable_registration', '__return_true' );
GFUser::gf_create_user( $entry, $form );
// Make sure it's not run twice.
add_filter( 'gform_disable_registration', '__return_true' );
return true;
}
/**
* Prevent the feeds assigned to the current step from being processed by the associated add-on.
*/
public function intercept_submission() {
if ( class_exists( 'GF_User_Registration' ) ) {
parent::intercept_submission();
return;
}
add_filter( 'gform_disable_registration', '__return_true' );
}
/**
* Returns the feed name.
*
* @param array $feed The feed properties.
*
* @return string
*/
public function get_feed_label( $feed ) {
if ( class_exists( 'GF_User_Registration' ) ) {
return parent::get_feed_label( $feed );
}
$label = $feed['meta']['feed_type'] == 'create' ? __( 'Create', 'gravityflow' ) : __( 'Update', 'gravityflow' );
return $label;
}
/**
* Displays content inside the Workflow metabox on the workflow detail page.
*
* @param array $form The Form array which may contain validation details.
* @param array $args Additional args which may affect the display.
*/
public function workflow_detail_box( $form, $args ) {
$step_status = $this->get_status();
$status_label = $this->get_status_label( $step_status );
$display_step_status = (bool) $args['step_status'];
?>
<h4 style="margin-bottom:10px;"><?php echo $this->get_name() . ' (' . $status_label . ')' ?></h4>
<?php if ( $display_step_status ) : ?>
<div>
<ul>
<li>
<?php
echo sprintf( '%s: %s', esc_html__( 'User Registration', 'gravityflow' ), $status_label );
?>
</li>
</ul>
</div>
<?php
endif;
}
/**
* Displays content inside the Workflow metabox on the Gravity Forms Entry Detail page.
*
* @param array $form The current form.
*/
public function entry_detail_status_box( $form ) {
$step_status = $this->get_status();
$status_label = $this->get_status_label( $step_status );
?>
<h4 style="padding:10px;"><?php echo $this->get_name() . ': ' . $status_label ?></h4>
<div style="padding:10px;">
<ul>
<?php
echo sprintf( '%s: %s', esc_html__( 'User Registration', 'gravityflow' ), $status_label );
?>
</ul>
</div>
<?php
}
/**
* Target for the gform_user_registered hook; completes the step.
*
* @param int $user_id The ID of the new user.
* @param array $feed The feed properties.
* @param array $entry The current entry.
*/
public static function action_gform_user_registered( $user_id, $feed, $entry ) {
$api = new Gravity_Flow_API( $entry['form_id'] );
$step = $api->get_current_step( $entry );
if ( ! $step ) {
return;
}
if ( $step->get_type() == 'user_registration' ) {
$entry_id = $entry['id'];
/* @var Gravity_Flow_Step_Feed_Add_On $step */
GFFormsModel::update_lead_property( $entry_id, 'created_by', $user_id, false, true );
$activation_enabled = isset( $feed['meta']['userActivationEnable'] ) && $feed['meta']['userActivationEnable'];
if ( $activation_enabled ) {
$label = $step->get_feed_label( $feed );
$step->add_note( sprintf( esc_html__( 'User Registration feed processed: %s', 'gravityflow' ), $label ) );
$step->log_debug( __METHOD__ . '() - Feed processing complete: ' . $label );
$feed_id = $feed['id'];
$add_on_feeds = $step->get_processed_add_on_feeds( $entry_id );
if ( ! in_array( $feed_id, $add_on_feeds ) ) {
$add_on_feeds[] = $feed_id;
$step->update_processed_feeds( $add_on_feeds, $entry_id );
$api->process_workflow( $entry_id );
}
}
}
}
}
Gravity_Flow_Steps::register( new Gravity_Flow_Step_Feed_User_Registration() );

View File

@@ -0,0 +1,322 @@
<?php
/**
* Gravity Flow Step Feed WP E-Signature
*
* @package GravityFlow
* @subpackage Classes/Gravity_Flow_Step_Feed_Esign
* @copyright Copyright (c) 2015-2018, Steven Henty S.L.
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
* @since 1.3.3-dev
*/
if ( ! class_exists( 'GFForms' ) ) {
die();
}
/**
* Class Gravity_Flow_Step_Feed_Esign
*/
class Gravity_Flow_Step_Feed_Esign extends Gravity_Flow_Step_Feed_Add_On {
/**
* The step type.
*
* @var string
*/
public $_step_type = 'wp-e-signature';
/**
* The name of the class used by the add-on.
*
* @var string
*/
protected $_class_name = 'GFEsignAddOn';
/**
* The slug used by the add-on.
*
* @var string
*/
protected $_slug = 'esig-gf';
/**
* The E-Signature feed ID.
*
* @var int
*/
protected $_feed_id;
/**
* Returns the step label.
*
* @return string
*/
public function get_label() {
return 'WP E-Signature';
}
/**
* Returns the feed name.
*
* @param array $feed The E-Signature feed properties.
*
* @return string
*/
public function get_feed_label( $feed ) {
$sad_page_id = rgars( $feed, 'meta/esig_gf_sad' );
$sad = new esig_sad_document();
$document_id = $sad->get_sad_id( $sad_page_id );
$document_model = new WP_E_Document();
$document = $document_model->getDocument( $document_id );
return $document->document_title;
}
/**
* Returns the URL for the step icon.
*
* @return string
*/
public function get_icon_url() {
return $this->get_base_url() . '/images/esig-icon.png';
}
/**
* Returns an array of settings for this step type.
*
* @return array
*/
public function get_settings() {
$settings = parent::get_settings();
if ( ! $this->is_supported() ) {
return $settings;
}
$settings_api = $this->get_common_settings_api();
$fields = array(
$settings_api->get_setting_assignee_type(),
$settings_api->get_setting_assignees(),
$settings_api->get_setting_assignee_routing(),
$settings_api->get_setting_notification_tabs( array(
array(
'label' => __( 'Assignee Email', 'gravityflow' ),
'id' => 'tab_assignee_notification',
'fields' => $settings_api->get_setting_notification( array(
'type' => 'assignee',
'label' => __( 'Send Email to the assignee(s).', 'gravityflow' ),
'tooltip' => __( 'Enable this setting to send email to each of the assignees as soon as the entry has been assigned. If a role is configured to receive emails then all the users with that role will receive the email.', 'gravityflow' ),
'default_message' => __( 'A new document has been generated and requires a signature. Please check your Workflow Inbox.', 'gravityflow' ),
'resend_enabled' => true,
) ),
)
) ),
$settings_api->get_setting_instructions( esc_html__( 'Instructions: check the signature invite status in the WP E-Signature section of the Workflow sidebar and resend if necessary.', 'gravityflow' ) ),
$settings_api->get_setting_display_fields(),
);
$settings['fields'] = array_merge( $settings['fields'], $fields );
return $settings;
}
/**
* Prevent the feeds assigned to the current step from being processed by the associated add-on.
*/
public function intercept_submission() {
parent::intercept_submission();
remove_filter( 'gform_confirmation', array( ESIG_GRAVITY_Admin::get_instance(), 'reroute_confirmation' ) );
}
/**
* Processes this step.
*
* @return bool Is the step complete?
*/
public function process() {
$complete = parent::process();
$this->assign();
return $complete;
}
/**
* Processes the given feed for the add-on.
*
* @param array $feed The add-on feed properties.
*
* @return bool Is feed processing complete?
*/
public function process_feed( $feed ) {
$this->_feed_id = $feed['id'];
add_action( 'esig_sad_document_invite_send', array( $this, 'sad_document_invite_send' ) );
$feed['meta']['esign_gf_logic'] = 'email';
parent::process_feed( $feed );
return false;
}
/**
* Determines if this step type is supported.
*
* @return bool
*/
public function is_supported() {
return parent::is_supported() && class_exists( 'esig_sad_document' ) && class_exists( 'WP_E_Document' );
}
/**
* Target of esig_sad_document_invite_send hook. Store the feed id which created this document in the WP E-Signature meta.
*
* @param array $args The properties related to the document which was saved.
*/
public function sad_document_invite_send( $args ) {
if ( ! empty( $this->_feed_id ) && class_exists( 'WP_E_Meta' ) ) {
$sig_meta_api = new WP_E_Meta();
$sig_meta_api->add( $args['document']->document_id, 'esig_gravity_feed_id', $this->_feed_id );
$this->save_document_id( $args['document']->document_id );
}
}
/**
* Store the current document ID in the entry meta for this step.
*
* @param int $document_id The documents unique ID assigned by WP E-Signature.
*/
public function save_document_id( $document_id ) {
$document_ids = $this->get_document_ids();
if ( ! in_array( $document_id, $document_ids ) ) {
$document_ids[] = $document_id;
}
gform_update_meta( $this->get_entry_id(), 'workflow_step_' . $this->get_id() . '_document_ids', $document_ids );
}
/**
* Retrieve this entries document IDs for the current step.
*
* @return array
*/
public function get_document_ids() {
$document_ids = gform_get_meta( $this->get_entry_id(), 'workflow_step_' . $this->get_id() . '_document_ids' );
if ( empty( $document_ids ) ) {
$document_ids = array();
}
return $document_ids;
}
/**
* Displays content inside the Workflow metabox on the workflow detail page.
*
* @param array $form The Form array which may contain validation details.
* @param array $args Additional args which may affect the display.
*/
public function workflow_detail_box( $form, $args ) {
$document_ids = $this->get_document_ids();
if ( ! empty( $document_ids ) && class_exists( 'WP_E_Document' ) ) {
echo sprintf( '<h4 style="margin-bottom:10px;">%s</h4>', $this->get_label() );
$doc_api = new WP_E_Document();
$invite_api = new WP_E_Invite();
global $current_user;
$user_email = $current_user->user_email;
if ( empty( $user_email ) ) {
$assignee_key = gravity_flow()->get_current_user_assignee_key();
list( $type, $user_id ) = rgexplode( '|', $assignee_key, 2 );
$user_email = $type == 'email' ? $user_id : '';
}
foreach ( $document_ids as $document_id ) {
$document = $doc_api->getDocument( $document_id );
echo sprintf( '%s: %s<br><br>', esc_html__( 'Title', 'gravityflow' ), esc_html( $document->document_title ) );
echo sprintf( '%s: %s', esc_html__( 'Invite Status', 'gravityflow' ), $invite_api->is_invite_sent( $document_id ) ? esc_html__( 'Sent', 'gravityflow' ) : esc_html__( 'Error: Not Sent', 'gravityflow' ) );
echo '&nbsp;';
$params = array(
'page' => 'esign-resend_invite-document',
'document_id' => $document_id,
);
$resend_url = add_query_arg( $params, admin_url() );
echo sprintf( '&nbsp;-&nbsp;<a href="%s">%s</a><br><br>', esc_url( $resend_url ), esc_html__( 'Resend', 'gravityflow' ) );
$text = '';
if ( ! empty( $user_email ) ) {
$invitations = $invite_api->getInvitations( $document_id );
if ( $user_email == $invitations[0]->user_email ) {
$url = $invite_api->get_invite_url( $invitations[0]->invite_hash, $document->document_checksum );
$text = esc_html__( 'Review &amp; Sign', 'gravityflow' );
}
}
if ( empty( $url ) || empty( $text ) ) {
$url = $invite_api->get_preview_url( $document_id );
$text = esc_html__( 'Preview', 'gravityflow' );
}
echo '<br /><div class="gravityflow-action-buttons">';
echo sprintf( '<a href="%s" target="_blank" class="button button-large button-primary">%s</a><br><br>', $url, $text );
echo '</div>';
}
}
}
/**
* Deletes custom entry meta when the step or workflow is restarted.
*/
public function restart_action() {
gform_delete_meta( $this->get_entry_id(), 'workflow_step_' . $this->get_id() . '_document_ids' );
}
}
Gravity_Flow_Steps::register( new Gravity_Flow_Step_Feed_Esign() );
/**
* Resume the workflow if the completed document originated from a feed processed by one of our steps.
*
* @param array $args The properties related to the completed document.
*/
function gravity_flow_step_esign_signature_saved( $args ) {
if ( class_exists( 'WP_E_Meta' ) ) {
$sig_meta_api = new WP_E_Meta();
$entry_id = $sig_meta_api->get( $args['invitation']->document_id, 'esig_gravity_entry_id' );
$feed_id = $sig_meta_api->get( $args['invitation']->document_id, 'esig_gravity_feed_id' );
if ( $entry_id && $feed_id ) {
$entry = GFAPI::get_entry( $entry_id );
if ( ! is_wp_error( $entry ) && is_array( $entry ) && rgar( $entry, 'workflow_final_status' ) == 'pending' ) {
$api = new Gravity_Flow_API( $entry['form_id'] );
/* @var Gravity_Flow_Step_Feed_Esign $step */
$step = $api->get_current_step( $entry );
if ( $step ) {
$feed = gravity_flow()->get_feed( $feed_id );
$label = $step->get_feed_label( $feed );
$step->add_note( sprintf( esc_html__( 'Document signed: %s', 'gravityflow' ), $label ) );
$step->log_debug( __METHOD__ . '() - Feed processing complete: ' . $label );
$add_on_feeds = $step->get_processed_add_on_feeds( $entry_id );
if ( ! in_array( $feed_id, $add_on_feeds ) ) {
$add_on_feeds[] = $feed_id;
$step->update_processed_feeds( $add_on_feeds, $entry_id );
$form = GFAPI::get_form( $entry['form_id'] );
gravity_flow()->process_workflow( $form, $entry_id );
}
}
}
}
}
}
add_action( 'esig_signature_saved', 'gravity_flow_step_esign_signature_saved' );

View File

@@ -0,0 +1,129 @@
<?php
/**
* Gravity Flow Step Feed Zapier
*
* @package GravityFlow
* @subpackage Classes/Gravity_Flow_Step_Feed_Zapier
* @copyright Copyright (c) 2015-2018, Steven Henty S.L.
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
* @since 1.0
*/
if ( ! class_exists( 'GFForms' ) ) {
die();
}
/**
* Class Gravity_Flow_Step_Feed_Zapier
*/
class Gravity_Flow_Step_Feed_Zapier extends Gravity_Flow_Step_Feed_Add_On {
/**
* The step type.
*
* @var string
*/
public $_step_type = 'zapier';
/**
* The name of the class used by the add-on.
*
* @var string
*/
protected $_class_name = 'GFZapier';
/**
* The slug used by the add-on.
*
* @var string
*/
protected $_slug = 'gravityformszapier';
/**
* Returns the step label.
*
* @return string
*/
public function get_label() {
return 'Zapier';
}
/**
* Returns the URL for the step icon.
*
* @return string
*/
public function get_icon_url() {
return $this->get_base_url() . '/images/zapier-icon.svg';
}
/**
* Returns the feeds for the add-on.
*
* @return array
*/
public function get_feeds() {
if ( class_exists( 'GFZapierData' ) ) {
$form_id = $this->get_form_id();
$feeds = GFZapierData::get_feed_by_form( $form_id );
} else {
$feeds = array();
}
return $feeds;
}
/**
* Processes the given feed for the add-on.
*
* @param array $feed The add-on feed properties.
*
* @return bool Is feed processing complete?
*/
public function process_feed( $feed ) {
$form = $this->get_form();
$entry = $this->get_entry();
if ( method_exists( 'GFZapier', 'process_feed' ) ) {
GFZapier::process_feed( $feed, $entry, $form );
} else {
GFZapier::send_form_data_to_zapier( $entry, $form );
}
return true;
}
/**
* Prevent the feeds assigned to the current step from being processed by the associated add-on.
*/
public function intercept_submission() {
remove_action( 'gform_after_submission', array( 'GFZapier', 'send_form_data_to_zapier' ) );
}
/**
* Returns the feed name.
*
* @param array $feed The feed properties.
*
* @return string
*/
public function get_feed_label( $feed ) {
return $feed['name'];
}
/**
* Determines if the supplied feed should be processed.
*
* @param array $feed The current feed.
* @param array $form The current form.
* @param array $entry The current entry.
*
* @return bool
*/
public function is_feed_condition_met( $feed, $form, $entry ) {
return GFZapier::conditions_met( $form, $feed, $entry );
}
}
Gravity_Flow_Steps::register( new Gravity_Flow_Step_Feed_Zapier() );

View File

@@ -0,0 +1,46 @@
<?php
/**
* Gravity Flow Step Feed Zoho CRM
*
* @package GravityFlow
* @subpackage Classes/Gravity_Flow_Step_Feed_ZohoCRM
* @copyright Copyright (c) 2015-2018, Steven Henty S.L.
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
* @since 1.3.2-dev
*/
if ( ! class_exists( 'GFForms' ) ) {
die();
}
/**
* Class Gravity_Flow_Step_Feed_ZohoCRM
*/
class Gravity_Flow_Step_Feed_ZohoCRM extends Gravity_Flow_Step_Feed_Add_On {
/**
* The step type.
*
* @var string
*/
public $_step_type = 'zohocrm';
/**
* The name of the class used by the add-on.
*
* @var string
*/
protected $_class_name = 'GFZohoCRM';
/**
* Returns the step label.
*
* @return string
*/
public function get_label() {
return 'Zoho CRM';
}
}
Gravity_Flow_Steps::register( new Gravity_Flow_Step_Feed_ZohoCRM() );

View File

@@ -0,0 +1,176 @@
<?php
/**
* Gravity Flow Step Notification
*
* @package GravityFlow
* @subpackage Classes/Gravity_Flow_Step_Notification
* @copyright Copyright (c) 2015-2018, Steven Henty S.L.
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
* @since 1.0
*/
if ( ! class_exists( 'GFForms' ) ) {
die();
}
/**
* Class Gravity_Flow_Step_Notification
*/
class Gravity_Flow_Step_Notification extends Gravity_Flow_Step {
/**
* The step type.
*
* @var string
*/
public $_step_type = 'notification';
/**
* Returns the step label.
*
* @return string
*/
public function get_label() {
return esc_html__( 'Notification', 'gravityflow' );
}
/**
* Returns the HTML for the step icon.
*
* @return string
*/
public function get_icon_url() {
return '<i class="fa fa-envelope-o"></i>';
}
/**
* Returns an array of settings for this step type.
*
* @return array
*/
public function get_settings() {
$form = $this->get_form();
$choices = array();
foreach ( $form['notifications'] as $notification ) {
$choices[] = array(
'label' => $notification['name'],
'name' => 'notification_id_' . $notification['id'],
);
}
$fields = array(
array(
'name' => 'notification',
'label' => esc_html__( 'Gravity Forms Notifications', 'gravityflow' ),
'type' => 'checkbox',
'required' => false,
'choices' => $choices,
),
);
$settings_api = $this->get_common_settings_api();
$workflow_notification_fields = $settings_api->get_setting_notification( array(
'name_prefix' => 'workflow',
'label' => __( 'Workflow notification', 'gravityflow' ),
'tooltip' => __( 'Enable this setting to send an email.', 'gravityflow' ),
'checkbox_label' => __( 'Enabled', 'gravityflow' ),
'checkbox_tooltip' => '',
'send_to_fields' => true,
'resend_field' => false,
) );
return array(
'title' => 'Notification',
'fields' => array_merge( $fields, $workflow_notification_fields ),
);
}
/**
* Triggers sending of the selected notifications.
*
* @return bool
*/
function process() {
$this->log_debug( __METHOD__ . '(): starting' );
/* Ensure compatibility with Gravity PDF 3.x */
if ( defined( 'PDF_EXTENDED_VERSION' ) && version_compare( PDF_EXTENDED_VERSION, '4.0-beta1', '<' ) && class_exists( 'GFPDF_Core' ) ) {
global $gfpdf;
if ( empty( $gfpdf ) ) {
$gfpdf = new GFPDF_Core();
}
}
$entry = $this->get_entry();
$form = $this->get_form();
foreach ( $form['notifications'] as $notification ) {
$notification_id = $notification['id'];
$setting_key = 'notification_id_' . $notification_id;
if ( $this->{$setting_key} ) {
if ( ! GFCommon::evaluate_conditional_logic( rgar( $notification, 'conditionalLogic' ), $form, $entry ) ) {
$this->log_debug( __METHOD__ . "(): Notification conditional logic not met, not processing notification (#{$notification_id} - {$notification['name']})." );
continue;
}
GFCommon::send_notification( $notification, $form, $entry );
$this->log_debug( __METHOD__ . "(): Notification sent (#{$notification_id} - {$notification['name']})." );
$this->add_note( sprintf( esc_html__( 'Sent Notification: %s', 'gravityflow' ), $notification['name'] ) );
}
}
$this->send_workflow_notification();
return true;
}
/**
* Sends the workflow notification, if enabled.
*/
public function send_workflow_notification() {
if ( ! $this->workflow_notification_enabled ) {
return;
}
$type = 'workflow';
$assignees = $this->get_notification_assignees( $type );
if ( empty( $assignees ) ) {
return;
}
$notification = $this->get_notification( $type );
$this->send_notifications( $assignees, $notification );
$note = esc_html__( 'Sent Notification: ', 'gravityflow' ) . $this->get_name();
$this->add_note( $note );
}
/**
* Prevent the notifications assigned to the current step from being sent during form submission.
*/
public function intercept_submission() {
$form_id = $this->get_form_id();
add_filter( "gform_disable_notification_{$form_id}", array( $this, 'maybe_disable_notification' ), 10, 2 );
}
/**
* Prevents the current notification from being sent during form submission if it is selected for this step.
*
* @param bool $is_disabled Indicates if the current notification has already been disabled.
* @param array $notification The current notifications properties.
*
* @return bool
*/
public function maybe_disable_notification( $is_disabled, $notification ) {
$setting_key = 'notification_id_' . $notification['id'];
return $this->{$setting_key} ? true : $is_disabled;
}
}
Gravity_Flow_Steps::register( new Gravity_Flow_Step_Notification() );

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,90 @@
<?php
/**
* Gravity Flow Steps
*
*
* @package GravityFlow
* @subpackage Classes/Gravity_Flow_Steps
* @copyright Copyright (c) 2015-2018, Steven Henty S.L.
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
* @since 1.0
*/
if ( ! class_exists( 'GFForms' ) ) {
die();
}
class Gravity_Flow_Steps {
/* @var Gravity_Flow_Step[] */
private static $_steps = array();
/**
* @param Gravity_Flow_Step $step
*
* @throws Exception
*/
public static function register( $step ) {
if ( ! is_subclass_of( $step, 'Gravity_Flow_Step' ) ) {
throw new Exception( 'Must be a subclass of Gravity_Flow_Step' );
}
$step_type = $step->get_type();
if ( empty( $step_type ) ) {
throw new Exception( 'The step_type must be set' );
}
if ( isset( self::$_steps[ $step_type ] ) ) {
throw new Exception( 'Step type already registered: ' . $step_type );
}
self::$_steps[ $step_type ] = $step;
}
public static function exists( $step_type ) {
return isset( self::$_steps[ $step_type ] );
}
/**
* @param $step_type
*
* @return Gravity_Flow_Step
*/
public static function get_instance( $step_type ) {
return isset( self::$_steps[ $step_type ] ) ? self::$_steps[ $step_type ] : false;
}
/**
* Alias for get_instance()
*
* @param $step_type
*
* @return Gravity_Flow_Step
*/
public static function get( $step_type ) {
return self::get_instance( $step_type );
}
/**
* @return Gravity_Flow_Step[]
*/
public static function get_all() {
return self::$_steps;
}
/**
* @param $feed
*
* @return Gravity_Flow_Step | bool
*/
public static function create( $feed, $entry = null ) {
$step_type = $feed['meta']['step_type'];
if ( empty( $step_type ) || ! isset( self::$_steps[ $step_type ] ) ) {
return false;
}
$class = self::$_steps[ $step_type ];
$class_name = get_class( $class );
$step = new $class_name( $feed, $entry );
return $step;
}
}

2
includes/steps/index.php Normal file
View File

@@ -0,0 +1,2 @@
<?php
//Nothing to see here