示例#1
0
 public static function fulfill_order(&$entry, $transaction_id, $amount)
 {
     $config = self::get_config_by_entry($entry);
     if (!$config) {
         self::log_error("Order can't be fulfilled because feed wasn't found for form: {$entry["form_id"]}");
         return;
     }
     $form = RGFormsModel::get_form_meta($entry["form_id"]);
     if ($config["meta"]["delay_post"]) {
         self::log_debug("Creating post.");
         RGFormsModel::create_post($form, $entry);
     }
     if (isset($config["meta"]["delay_notifications"])) {
         //sending delayed notifications
         GFCommon::send_notifications($config["meta"]["selected_notifications"], $form, $entry, true, "form_submission");
     } else {
         //sending notifications using the legacy structure
         if ($config["meta"]["delay_notification"]) {
             self::log_debug("Sending admin notification.");
             GFCommon::send_admin_notification($form, $entry);
         }
         if ($config["meta"]["delay_autoresponder"]) {
             self::log_debug("Sending user notification.");
             GFCommon::send_user_notification($form, $entry);
         }
     }
     self::log_debug("Before gform_paypal_fulfillment.");
     do_action("gform_paypal_fulfillment", $entry, $config, $transaction_id, $amount);
 }
示例#2
0
 public function fulfill_order(&$entry, $transaction_id, $amount, $feed = null)
 {
     if (!$feed) {
         $feed = $this->get_payment_feed($entry);
     }
     $form = GFFormsModel::get_form_meta($entry['form_id']);
     if (rgars($feed, 'meta/delayPost')) {
         $this->log_debug(__METHOD__ . '(): Creating post.');
         $entry['post_id'] = GFFormsModel::create_post($form, $entry);
         $this->log_debug(__METHOD__ . '(): Post created.');
     }
     if (rgars($feed, 'meta/delayNotification')) {
         //sending delayed notifications
         $notifications = rgars($feed, 'meta/selectedNotifications');
         GFCommon::send_notifications($notifications, $form, $entry, true, 'form_submission');
     }
     do_action('gform_paypal_fulfillment', $entry, $feed, $transaction_id, $amount);
     if (has_filter('gform_paypal_fulfillment')) {
         $this->log_debug(__METHOD__ . '(): Executing functions hooked to gform_paypal_fulfillment.');
     }
 }
示例#3
0
 /**
  * Sends all active notifications for a form given an entry object and an event.
  *
  * @param $form
  * @param $entry
  * @param string $event Default = 'form_submission'
  * @param array  $data  Optional. Array of data which can be used in the notifications via the generic {object:property} merge tag.
  *
  * @return array
  */
 public static function send_notifications($form, $entry, $event = 'form_submission', $data = array())
 {
     if (rgempty('notifications', $form) || !is_array($form['notifications'])) {
         return array();
     }
     $entry_id = rgar($entry, 'id');
     GFCommon::log_debug("GFAPI::send_notifications(): Gathering notifications for {$event} event for entry #{$entry_id}.");
     $notifications_to_send = array();
     //running through filters that disable form submission notifications
     foreach ($form['notifications'] as $notification) {
         if (rgar($notification, 'event') != $event) {
             continue;
         }
         if ($event == 'form_submission') {
             if (rgar($notification, 'type') == 'user' && gf_apply_filters(array('gform_disable_user_notification', $form['id']), false, $form, $entry)) {
                 GFCommon::log_debug("GFAPI::send_notifications(): Notification is disabled by gform_disable_user_notification hook, not including notification (#{$notification['id']} - {$notification['name']}).");
                 //skip user notification if it has been disabled by a hook
                 continue;
             } elseif (rgar($notification, 'type') == 'admin' && gf_apply_filters(array('gform_disable_admin_notification', $form['id']), false, $form, $entry)) {
                 GFCommon::log_debug("GFAPI::send_notifications(): Notification is disabled by gform_disable_admin_notification hook, not including notification (#{$notification['id']} - {$notification['name']}).");
                 //skip admin notification if it has been disabled by a hook
                 continue;
             }
         }
         if (gf_apply_filters(array('gform_disable_notification', $form['id']), false, $notification, $form, $entry)) {
             GFCommon::log_debug("GFAPI::send_notifications(): Notification is disabled by gform_disable_notification hook, not including notification (#{$notification['id']} - {$notification['name']}).");
             //skip notifications if it has been disabled by a hook
             continue;
         }
         $notifications_to_send[] = $notification['id'];
     }
     GFCommon::send_notifications($notifications_to_send, $form, $entry, true, $event, $data);
 }
 /**
  * Delete entries
  * This function is used to delete entries with an ajax request
  * Could use better (or at least some) error handling
  */
 public function maybe_delete_entry()
 {
     if (isset($_POST["mode"]) && $_POST["mode"] == "delete" && isset($_POST["delete_id"]) && isset($_POST["form_id"])) {
         $form_id = $_POST["form_id"];
         $form = GFAPI::get_form($form_id);
         $settings = $this->get_form_settings($form);
         $enable_delete = $settings["enable_delete"];
         $delete_type = $settings["delete_type"];
         if ($enable_delete) {
             $delete_id = $_POST["delete_id"];
             $entry = GFAPI::get_entry($delete_id);
             if (!is_wp_error($entry)) {
                 if ($entry["created_by"] == $this->stickylist_get_current_user() || current_user_can('delete_others_posts') || current_user_can('stickylist_delete_entries')) {
                     if ($_POST["delete_post_id"] != null) {
                         $delete_post_id = $_POST["delete_post_id"];
                     } else {
                         $delete_post_id = "";
                     }
                     if ($delete_type == "trash") {
                         $entry["status"] = "trash";
                         $success = GFAPI::update_entry($entry, $delete_id);
                         if ($delete_post_id != "") {
                             wp_delete_post($delete_post_id, false);
                         }
                     }
                     if ($delete_type == "permanent") {
                         $success = GFAPI::delete_entry($delete_id);
                         if ($delete_post_id != "") {
                             wp_delete_post($delete_post_id, true);
                         }
                     }
                     if ($success) {
                         $notifications = $form["notifications"];
                         $notification_ids = array();
                         foreach ($notifications as $notification) {
                             $notification_type = $notification["stickylist_notification_type"];
                             if ($notification_type == "delete" || $notification_type == "all") {
                                 $id = $notification["id"];
                                 array_push($notification_ids, $id);
                             }
                         }
                         GFCommon::send_notifications($notification_ids, $form, $entry);
                     }
                 }
             }
         }
     }
 }
示例#5
0
/**
 * @param $lead_id
 */
function euzakupki_order_status_email_notification($lead_id)
{
    $lead = GFFormsModel::get_lead($lead_id);
    if (!$lead) {
        return;
    }
    $form = RGFormsModel::get_form_meta($lead['form_id']);
    if (!$form) {
        return;
    }
    $config = euzakupki_get_form_config($lead['form_id']);
    if (!$config) {
        return;
    }
    $notifications = json_decode($config['notifications'], ARRAY_A);
    $ids = array();
    foreach ($notifications as $item) {
        if (!isset($item['isActive'])) {
            continue;
        }
        $ids[] = $item['id'];
    }
    GFCommon::send_notifications($ids, $form, $lead);
}
示例#6
0
 /**
  * Fulfill order
  *
  * @param array $entry
  */
 public function fulfill_order($entry)
 {
     $feed = get_pronamic_gf_pay_feed_by_entry_id(rgar($entry, 'id'));
     if (null !== $feed) {
         $this->maybe_update_user_role($entry, $feed);
         $form = RGFormsModel::get_form_meta($entry['form_id']);
         // Delay post creation
         // @see https://github.com/gravityforms/gravityforms/blob/1.8.20.5/forms_model.php#L2383
         // @see https://github.com/gravityforms/gravityformspaypal/blob/1.10.3/paypal.php#L2411-L2415
         if ($feed->delay_post_creation) {
             RGFormsModel::create_post($form, $entry);
         }
         // Delay Aweber
         // @see https://github.com/gravityforms/gravityformsaweber/blob/1.4.2/aweber.php#L1167-L1197
         if ($feed->delay_aweber_subscription && Pronamic_WP_Pay_Class::method_exists('GFAWeber', 'export')) {
             call_user_func(array('GFAWeber', 'export'), $entry, $form, false);
             // @since 1.3.0
             // @see https://github.com/gravityforms/gravityformsaweber/blob/2.2.1/aweber.php#L48-L50
             // @see https://github.com/gravityforms/gravityforms/blob/1.9.10.15/includes/addon/class-gf-feed-addon.php#L43
             if (function_exists('gf_aweber')) {
                 $addon = gf_aweber();
                 if (method_exists($addon, 'maybe_process_feed')) {
                     $addon->maybe_process_feed($entry, $form);
                 }
             }
         }
         // Delay Campaign Monitor
         if ($feed->delay_campaignmonitor_subscription) {
             // @see https://github.com/gravityforms/gravityformscampaignmonitor/blob/2.5.1/campaignmonitor.php#L1184
             if (Pronamic_WP_Pay_Class::method_exists('GFCampaignMonitor', 'export')) {
                 call_user_func(array('GFCampaignMonitor', 'export'), $entry, $form, false);
             }
             // @since 1.3.0
             // @see https://github.com/gravityforms/gravityformscampaignmonitor/blob/3.3.2/campaignmonitor.php#L48-L50
             // @see https://github.com/gravityforms/gravityforms/blob/1.9.10.15/includes/addon/class-gf-feed-addon.php#L43
             if (function_exists('gf_campaignmonitor')) {
                 $addon = gf_campaignmonitor();
                 if (method_exists($addon, 'maybe_process_feed')) {
                     $addon->maybe_process_feed($entry, $form);
                 }
             }
         }
         // Delay Mailchimp
         if ($feed->delay_mailchimp_subscription) {
             // @see https://github.com/gravityforms/gravityformsmailchimp/blob/2.4.5/mailchimp.php#L1512
             if (Pronamic_WP_Pay_Class::method_exists('GFMailChimp', 'export')) {
                 call_user_func(array('GFMailChimp', 'export'), $entry, $form, false);
             }
             // @since 1.3.0
             // @see https://github.com/gravityforms/gravityformsmailchimp/blob/3.6.3/mailchimp.php#L48-L50
             // @see https://github.com/gravityforms/gravityforms/blob/1.9.10.15/includes/addon/class-gf-feed-addon.php#L43
             if (function_exists('gf_mailchimp')) {
                 $addon = gf_mailchimp();
                 if (method_exists($addon, 'maybe_process_feed')) {
                     $addon->maybe_process_feed($entry, $form);
                 }
             }
         }
         // Delay Zapier
         // @see https://github.com/gravityforms/gravityformszapier/blob/1.4.2/zapier.php#L469-L533
         if ($feed->delay_zapier && Pronamic_WP_Pay_Class::method_exists('GFZapier', 'send_form_data_to_zapier')) {
             call_user_func(array('GFZapier', 'send_form_data_to_zapier'), $entry, $form);
         }
         // Delay user registration
         // @see https://github.com/gravityforms/gravityformsuserregistration/blob/2.0/userregistration.php#L2133
         if ($feed->delay_user_registration && Pronamic_WP_Pay_Class::method_exists('GFUser', 'gf_create_user')) {
             call_user_func(array('GFUser', 'gf_create_user'), $entry, $form, false);
         }
         // Delay notifications
         // Determine if the feed has Gravity Form 1.7 Feed IDs
         if ($feed->has_delayed_notifications()) {
             // @see https://bitbucket.org/Pronamic/gravityforms/src/42773f75ad7ad9ac9c31ce149510ff825e4aa01f/common.php?at=1.7.8#cl-1512
             GFCommon::send_notifications($feed->delay_notification_ids, $form, $entry, true, 'form_submission');
         }
         if ($feed->delay_admin_notification && Pronamic_WP_Pay_Class::method_exists('GFCommon', 'send_admin_notification')) {
             // https://github.com/gravityforms/gravityforms/blob/1.8.9/common.php#L1265-L1270
             GFCommon::send_admin_notification($form, $entry);
         }
         if ($feed->delay_user_notification && Pronamic_WP_Pay_Class::method_exists('GFCommon', 'send_user_notification')) {
             // https://github.com/gravityforms/gravityforms/blob/1.8.9/common.php#L1258-L1263
             GFCommon::send_user_notification($form, $entry);
         }
     }
     // The Gravity Forms PayPal Add-On executes the 'gform_paypal_fulfillment' action
     do_action('gform_ideal_fulfillment', $entry, $feed);
 }
示例#7
0
 public function fulfill_order($entry, $transaction_id, $amount, $feed = null)
 {
     if (!$feed) {
         $this->log_error("Order can't be fulfilled because feed wasn't found for form: {$entry['form_id']}");
         return;
     }
     $form = GFFormsModel::get_form_meta($entry['form_id']);
     if (rgars($feed, 'meta/delayPost')) {
         $this->log_debug('Creating post.');
         GFFormsModel::create_post($form, $entry);
         $this->log_debug('Post created.');
     }
     if (rgars($feed, 'meta/delayNotification')) {
         //sending delayed notifications
         $notifications = rgars($feed, 'meta/selectedNotifications');
         GFCommon::send_notifications($notifications, $form, $entry, true, 'form_submission');
     }
     $this->log_debug('Before gform_paypal_fulfillment.');
     do_action('gform_paypal_fulfillment', $entry, $feed, $transaction_id, $amount);
     $this->log_debug('After gform_paypal_fulfillment.');
 }
 private function sendNotifications($form_id, $entry_id)
 {
     // Get the array info for our forms and entries
     // that we need to send notifications for
     $form = RGFormsModel::get_form_meta($form_id);
     $entry = RGFormsModel::get_lead($entry_id);
     // Loop through all the notifications for the
     // form so we know which ones to send
     $notification_ids = array();
     foreach ($form['notifications'] as $id => $info) {
         array_push($notification_ids, $id);
     }
     // Send the notifications
     GFCommon::send_notifications($notification_ids, $form, $entry);
 }