示例#1
0
 public static function handle_submission($form, &$lead, $ajax = false)
 {
     //creating entry in DB
     RGFormsModel::save_lead($form, $lead);
     //reading entry that was just saved
     $lead = RGFormsModel::get_lead($lead["id"]);
     $lead = GFFormsModel::set_entry_meta($lead, $form);
     do_action('gform_entry_created', $lead, $form);
     $lead = apply_filters('gform_entry_post_save', $lead, $form);
     RGFormsModel::set_current_lead($lead);
     //if Akismet plugin is installed, run lead through Akismet and mark it as Spam when appropriate
     $is_spam = GFCommon::akismet_enabled($form['id']) && GFCommon::is_akismet_spam($form, $lead);
     if (!$is_spam) {
         GFCommon::create_post($form, $lead);
         //send notifications
         GFCommon::send_form_submission_notifications($form, $lead);
     } else {
         //marking entry as spam
         RGFormsModel::update_lead_property($lead["id"], "status", "spam", false, true);
         $lead["status"] = "spam";
     }
     //display confirmation message or redirect to confirmation page
     return self::handle_confirmation($form, $lead, $ajax);
 }
示例#2
0
 public static function handle_submission($form, &$lead, $ajax = false)
 {
     $lead_id = gf_apply_filters(array('gform_entry_id_pre_save_lead', $form['id']), null, $form);
     if (!empty($lead_id)) {
         if (empty($lead)) {
             $lead = array();
         }
         $lead['id'] = $lead_id;
     }
     //creating entry in DB
     RGFormsModel::save_lead($form, $lead);
     //reading entry that was just saved
     $lead = RGFormsModel::get_lead($lead['id']);
     $lead = GFFormsModel::set_entry_meta($lead, $form);
     //if Akismet plugin is installed, run lead through Akismet and mark it as Spam when appropriate
     $is_spam = GFCommon::akismet_enabled($form['id']) && GFCommon::is_akismet_spam($form, $lead);
     /**
      * A filter to set if an entry is spam
      *
      * @param int $form['id'] The Form ID to filter through (take directly from the form object)
      * @param bool $is_spam True or false to filter if the entry is spam
      * @param array $form The Form object to filer through
      * @param array $lead The Lead object to filter through
      */
     $is_spam = gf_apply_filters(array('gform_entry_is_spam', $form['id']), $is_spam, $form, $lead);
     if (GFCommon::spam_enabled($form['id'])) {
         GFCommon::log_debug('GFFormDisplay::handle_submission(): Akismet integration enabled OR gform_entry_is_spam hook in use.');
         $log_is_spam = $is_spam ? 'Yes' : 'No';
         GFCommon::log_debug("GFFormDisplay::handle_submission(): Is entry considered spam? {$log_is_spam}.");
     }
     if ($is_spam) {
         //marking entry as spam
         RGFormsModel::update_lead_property($lead['id'], 'status', 'spam', false, true);
         $lead['status'] = 'spam';
     }
     /**
      * Fired after an entry is created
      *
      * @param array $lead The Entry object
      * @param array $form The Form object
      */
     do_action('gform_entry_created', $lead, $form);
     $lead = gf_apply_filters(array('gform_entry_post_save', $form['id']), $lead, $form);
     RGFormsModel::set_current_lead($lead);
     if (!$is_spam) {
         GFCommon::create_post($form, $lead);
         //send notifications
         GFCommon::send_form_submission_notifications($form, $lead);
     }
     self::clean_up_files($form);
     // remove incomplete submission and purge expired
     if (rgars($form, 'save/enabled')) {
         GFFormsModel::delete_incomplete_submission(rgpost('gform_resume_token'));
         GFFormsModel::purge_expired_incomplete_submissions();
     }
     //display confirmation message or redirect to confirmation page
     return self::handle_confirmation($form, $lead, $ajax);
 }
示例#3
0
 public static function handle_submission($form, &$lead, $ajax = false)
 {
     $lead_id = apply_filters("gform_entry_id_pre_save_lead{$form["id"]}", apply_filters("gform_entry_id_pre_save_lead", null, $form), $form);
     if (!empty($lead_id)) {
         if (empty($lead)) {
             $lead = array();
         }
         $lead["id"] = $lead_id;
     }
     //creating entry in DB
     RGFormsModel::save_lead($form, $lead);
     //reading entry that was just saved
     $lead = RGFormsModel::get_lead($lead["id"]);
     $lead = GFFormsModel::set_entry_meta($lead, $form);
     do_action('gform_entry_created', $lead, $form);
     $lead = apply_filters('gform_entry_post_save', $lead, $form);
     RGFormsModel::set_current_lead($lead);
     //if Akismet plugin is installed, run lead through Akismet and mark it as Spam when appropriate
     $is_spam = GFCommon::akismet_enabled($form['id']) && GFCommon::is_akismet_spam($form, $lead);
     $is_spam = apply_filters('gform_entry_is_spam', $is_spam, $form, $lead);
     $is_spam = apply_filters("gform_entry_is_spam_{$form['id']}", $is_spam, $form, $lead);
     GFCommon::log_debug("Checking for spam...");
     GFCommon::log_debug("Is entry considered spam? {$is_spam}.");
     if (!$is_spam) {
         GFCommon::create_post($form, $lead);
         //send notifications
         GFCommon::send_form_submission_notifications($form, $lead);
     } else {
         //marking entry as spam
         RGFormsModel::update_lead_property($lead["id"], "status", "spam", false, true);
         $lead["status"] = "spam";
     }
     self::clean_up_files($form);
     //display confirmation message or redirect to confirmation page
     return self::handle_confirmation($form, $lead, $ajax);
 }