public static function valid_gravity_forms()
 {
     $form_id = isset($_POST["gform_submit"]) ? $_POST["gform_submit"] : 0;
     if ($form_id) {
         $form_info = RGFormsModel::get_form($form_id);
         $is_valid_form = $form_info && $form_info->is_active;
         if ($is_valid_form) {
             return true;
         }
     }
     return false;
 }
Beispiel #2
0
 /**
  * Returns the form object for a given Form ID.
  *
  * @access public
  * @param mixed $form_id
  * @return mixed False: no form ID specified or Gravity Forms isn't active. Array: Form returned from Gravity Forms
  */
 public static function get_form($form_id)
 {
     if (empty($form_id)) {
         return false;
     }
     if (class_exists('GFAPI')) {
         return GFAPI::get_form($form_id);
     }
     if (class_exists('RGFormsModel')) {
         return RGFormsModel::get_form($form_id);
     }
     return false;
 }
function cron_tpl_merge_process($tpls, $entry, $type = "", $invoice_number = "")
{
    echo "inside merge process.<br/>";
    require_once "D:\\inetpub\\app\\wwwroot\\wp-content\\plugins\\templatemerge\\phpdocx-v4\\classes\\TransformDocAdv.inc";
    require_once "D:\\inetpub\\app\\wwwroot\\wp-content\\plugins\\templatemerge\\phpdocx-v4\\classes\\CreateDocx.inc";
    $final_doc_url = "";
    $formdetail = RGFormsModel::get_form($entry["form_id"]);
    $new_xml = array();
    $unique_number = date('ymdhis') . "-" . $entry["id"];
    $n = str_replace('+', '_', urlencode($formdetail->title)) . ($type != "" ? "_" . $type : "") . "_" . $unique_number . '-cron.docx';
    if ($type == "Invoice" && $invoice_number == "") {
        $invoice_number = generate_invoice_number();
    }
    $i = 1;
    foreach ($tpls as $tpl) {
        $file = $tpl['file'];
        $value = $tpl['values'];
        $value["Invoice_number"] = $invoice_number;
        if (!empty($file['dir_path']) && !empty($file['filepath'])) {
            $cookie_file_path = $file['filepath'];
            /*echo '<br/>Cookie path: '.$cookie_file_path;
            		if (!file_exists($cookie_file_path)) {
                           echo 'file does not exist';
                       }
                       else {
                       	echo 'file exists';
                       }*/
            //Create PHPDocx object using the template file defined above.
            $docx = new CreateDocxFromTemplate($cookie_file_path);
            $variables = array();
            $variables_html = array();
            foreach ($value as $k => $v) {
                $k_val = explode("-", $k);
                $e_val = array("SIGNED", "PRESENCE", "LengthContent");
                if (count($k_val) > 1 && in_array($k_val[1], $e_val)) {
                    $variables_html[$k] = $v;
                } else {
                    $variables[$k] = $v;
                }
            }
            //Load the array into the PHPDocx object so that the variable values are inserted into the document template.
            $docx->replaceVariableByText($variables);
            if (!empty($variables_html)) {
                foreach ($variables_html as $hk => $hv) {
                    if (!empty($hv)) {
                        $docx->replaceVariableByHTML($hk, 'inline', $hv, array());
                    } else {
                        $docx->replaceVariableByText(array($hk => ""));
                    }
                }
            }
            //echo '<br/>About to check if file exists...';
            if (!file_exists($file['dir_path'] . '/doc/temps/cron/')) {
                mkdir($file['dir_path'] . '/doc/temps/cron/', 0777, true);
            }
            //Define the output location and name of the document to be saved (e.g. Saves in 'Output' folder relative to the location
            //Of this script, and the name of the file will be 'testDeed'.
            $outputWordFileNameAndPath = $file['dir_path'] . '/doc/temps/cron/' . date('ymdhis') . $i . '-cron';
            $newfile = $outputWordFileNameAndPath . ".docx";
            $newfile_pdf = $outputWordFileNameAndPath . ".pdf";
            //Define the base directory
            $baseDirectory = '';
            //Create the document and save it.
            $docx->createDocx($outputWordFileNameAndPath);
            //Conver the document to PDF and save.
            $docx->transformDocxUsingMSWord($baseDirectory . $outputWordFileNameAndPath . '.docx', $baseDirectory . $outputWordFileNameAndPath . '.pdf');
            if (file_exists($newfile_pdf)) {
                //chmod($newfile_pdf, 0777);
                $new_xml['temp_file'][] = $newfile_pdf;
                //chmod($newfile_pdf, 0777);
            }
        }
        $i++;
    }
    $c = count($new_xml['temp_file']);
    if (!file_exists($file['dir_path'] . '/doc/cron/')) {
        mkdir($file['dir_path'] . '/doc/cron/', 0777, true);
    }
    $final_doc = $file['dir_path'] . '/doc/cron/' . $n;
    $final_doc = str_replace('.docx', '.pdf', $final_doc);
    $final_doc = str_replace("/", "\\", $final_doc);
    $final_doc = str_replace("\\", "\\\\", $final_doc);
    $final_doc_url = $file['dir_url'] . '/doc/cron/' . $n;
    $final_doc_url = str_replace('.docx', '.pdf', $final_doc_url);
    if ($c > 1) {
        $alldoc = $new_xml['temp_file'];
        cron_mergerAllPdf($alldoc, $final_doc);
    } else {
        copy($new_xml['temp_file'][0], $final_doc);
    }
    if (file_exists($final_doc)) {
        chmod($final_doc, 0777);
        foreach ($new_xml['temp_file'] as $y) {
            if (file_exists(ConvertDirectoryPath($y))) {
                chmod(ConvertDirectoryPath($y), 0777);
            }
            @unlink(ConvertDirectoryPath($y));
            $y = str_replace(".pdf", ".docx", $y);
            @unlink(ConvertDirectoryPath($y));
        }
        cron_SaveToDB($final_doc_url, $final_doc, $entry["id"], $type, $invoice_number);
        return $final_doc_url;
    }
    foreach ($new_xml['temp_file'] as $y) {
        if (file_exists(ConvertDirectoryPath($y))) {
            chmod(ConvertDirectoryPath($y), 0777);
        }
        @unlink(ConvertDirectoryPath($y));
        $y = str_replace(".pdf", ".docx", $y);
        @unlink(ConvertDirectoryPath($y));
    }
    return "";
}
 /**
  * Update lead status of the specified payment
  *
  * @param string $payment
  */
 public function update_status(Pronamic_Pay_Payment $payment, $can_redirect = false)
 {
     $lead_id = $payment->get_source_id();
     $lead = RGFormsModel::get_lead($lead_id);
     if (!$lead) {
         return;
     }
     $form_id = $lead['form_id'];
     $form = RGFormsModel::get_form($form_id);
     $feed = get_pronamic_gf_pay_feed_by_entry_id($lead_id);
     if (!$feed) {
         return;
     }
     $data = new Pronamic_WP_Pay_Extensions_GravityForms_PaymentData($form, $lead, $feed);
     switch ($payment->status) {
         case Pronamic_WP_Pay_Statuses::CANCELLED:
             $lead[Pronamic_WP_Pay_Extensions_GravityForms_LeadProperties::PAYMENT_STATUS] = Pronamic_WP_Pay_Extensions_GravityForms_PaymentStatuses::CANCELLED;
             break;
         case Pronamic_WP_Pay_Statuses::EXPIRED:
             $lead[Pronamic_WP_Pay_Extensions_GravityForms_LeadProperties::PAYMENT_STATUS] = Pronamic_WP_Pay_Extensions_GravityForms_PaymentStatuses::EXPIRED;
             break;
         case Pronamic_WP_Pay_Statuses::FAILURE:
             $lead[Pronamic_WP_Pay_Extensions_GravityForms_LeadProperties::PAYMENT_STATUS] = Pronamic_WP_Pay_Extensions_GravityForms_PaymentStatuses::FAILED;
             break;
         case Pronamic_WP_Pay_Statuses::SUCCESS:
             if (!Pronamic_WP_Pay_Extensions_GravityForms_Entry::is_payment_approved($lead)) {
                 // Only fullfill order if the payment isn't approved already
                 $lead[Pronamic_WP_Pay_Extensions_GravityForms_LeadProperties::PAYMENT_STATUS] = Pronamic_WP_Pay_Extensions_GravityForms_PaymentStatuses::APPROVED;
                 // @see https://github.com/wp-premium/gravityformspaypal/blob/2.3.1/class-gf-paypal.php#L1741-L1742
                 if ($this->addon) {
                     $action = array('id' => $payment->get_transaction_id(), 'type' => 'complete_payment', 'transaction_id' => $payment->get_transaction_id(), 'amount' => $payment->get_amount(), 'entry_id' => $lead['id']);
                     $this->addon->complete_payment($lead, $action);
                 }
                 $this->fulfill_order($lead);
             }
             break;
         case Pronamic_WP_Pay_Statuses::OPEN:
         default:
             // Nothing to do.
             break;
     }
     // Update payment status property of lead
     Pronamic_WP_Pay_Extensions_GravityForms_GravityForms::update_entry_property($lead['id'], Pronamic_WP_Pay_Extensions_GravityForms_LeadProperties::PAYMENT_STATUS, $lead[Pronamic_WP_Pay_Extensions_GravityForms_LeadProperties::PAYMENT_STATUS]);
 }
 public static function get_form($form_id, $display_title = true, $display_description = true, $force_display = false, $field_values = null, $ajax = false, $tabindex = 1)
 {
     //looking up form id by form name
     if (!is_numeric($form_id)) {
         $form_id = RGFormsModel::get_form_id($form_id);
     }
     //reading form metadata
     $form = RGFormsModel::get_form_meta($form_id, true);
     $form = RGFormsModel::add_default_properties($form);
     //disable ajax if form has a reCAPTCHA field (not supported).
     if ($ajax && self::has_recaptcha_field($form)) {
         $ajax = false;
     }
     $is_postback = false;
     $is_valid = true;
     $confirmation_message = "";
     $page_number = 1;
     //If form was submitted, read variables set during form submission procedure
     $submission_info = isset(self::$submission[$form_id]) ? self::$submission[$form_id] : false;
     if ($submission_info) {
         $is_postback = true;
         $is_valid = rgar($submission_info, "is_valid") || rgar($submission_info, "is_confirmation");
         $form = $submission_info["form"];
         $lead = $submission_info["lead"];
         $confirmation_message = rgget("confirmation_message", $submission_info);
         if ($is_valid && !RGForms::get("is_confirmation", $submission_info)) {
             if ($submission_info["page_number"] == 0) {
                 //post submission hook
                 do_action("gform_post_submission", $lead, $form);
                 do_action("gform_post_submission_{$form["id"]}", $lead, $form);
             } else {
                 //change page hook
                 do_action("gform_post_paging", $form, $submission_info["source_page_number"], $submission_info["page_number"]);
                 do_action("gform_post_paging_{$form["id"]}", $form, $submission_info["source_page_number"], $submission_info["page_number"]);
             }
         }
     } else {
         if (!current_user_can("administrator")) {
             RGFormsModel::insert_form_view($form_id, $_SERVER['REMOTE_ADDR']);
         }
     }
     if (rgar($form, "enableHoneypot")) {
         $form["fields"][] = self::get_honeypot_field($form);
     }
     //Fired right before the form rendering process. Allow users to manipulate the form object before it gets displayed in the front end
     $form = apply_filters("gform_pre_render_{$form_id}", apply_filters("gform_pre_render", $form, $ajax), $ajax);
     if ($form == null) {
         return "<p>" . __("Oops! We could not locate your form.", "gravityforms") . "</p>";
     }
     $has_pages = self::has_pages($form);
     //calling tab index filter
     GFCommon::$tab_index = apply_filters("gform_tabindex_{$form_id}", apply_filters("gform_tabindex", $tabindex, $form), $form);
     //Don't display inactive forms
     if (!$force_display && !$is_postback) {
         $form_info = RGFormsModel::get_form($form_id);
         if (!$form_info->is_active) {
             return "";
         }
         // If form requires login, check if user is logged in
         if (rgar($form, "requireLogin")) {
             if (!is_user_logged_in()) {
                 return empty($form["requireLoginMessage"]) ? "<p>" . __("Sorry. You must be logged in to view this form.", "gravityforms") . "</p>" : "<p>" . GFCommon::gform_do_shortcode($form["requireLoginMessage"]) . "</p>";
             }
         }
     }
     // show the form regardless of the following validations when force display is set to true
     if (!$force_display) {
         $form_schedule_validation = self::validate_form_schedule($form);
         // if form schedule validation fails AND this is not a postback, display the validation error
         // if form schedule validation fails AND this is a postback, make sure is not a valid submission (enables display of confirmation message)
         if ($form_schedule_validation && !$is_postback || $form_schedule_validation && $is_postback && !$is_valid) {
             return $form_schedule_validation;
         }
         $entry_limit_validation = self::validate_entry_limit($form);
         // refer to form schedule condition notes above
         if ($entry_limit_validation && !$is_postback || $entry_limit_validation && $is_postback && !$is_valid) {
             return $entry_limit_validation;
         }
     }
     $form_string = "";
     //When called via a template, this will enqueue the proper scripts
     //When called via a shortcode, this will be ignored (too late to enqueue), but the scripts will be enqueued via the enqueue_scripts event
     self::enqueue_form_scripts($form, $ajax);
     if (empty($confirmation_message)) {
         $wrapper_css_class = GFCommon::get_browser_class() . " gform_wrapper";
         if (!$is_valid) {
             $wrapper_css_class .= " gform_validation_error";
         }
         //Hidding entire form if conditional logic is on to prevent "hidden" fields from blinking. Form will be set to visible in the conditional_logic.php after the rules have been applied.
         $style = self::has_conditional_logic($form) ? "style='display:none'" : "";
         $custom_wrapper_css_class = !empty($form["cssClass"]) ? " {$form["cssClass"]}_wrapper" : "";
         $form_string .= "\n                <div class='{$wrapper_css_class}{$custom_wrapper_css_class}' id='gform_wrapper_{$form_id}' " . $style . ">";
         $action = add_query_arg(array());
         $default_anchor = $has_pages || $ajax ? true : false;
         $use_anchor = apply_filters("gform_confirmation_anchor_{$form["id"]}", apply_filters("gform_confirmation_anchor", $default_anchor));
         if ($use_anchor !== false) {
             $form_string .= "<a id='gf_{$form_id}' name='gf_{$form_id}' class='gform_anchor' ></a>";
             $action .= "#gf_{$form_id}";
         }
         $target = $ajax ? "target='gform_ajax_frame_{$form_id}'" : "";
         $form_css_class = !empty($form["cssClass"]) ? "class='{$form["cssClass"]}'" : "";
         $action = esc_attr($action);
         $form_string .= apply_filters("gform_form_tag_{$form_id}", apply_filters("gform_form_tag", "<form method='post' enctype='multipart/form-data' {$target} id='gform_{$form_id}' {$form_css_class} action='{$action}'>", $form), $form);
         if ($display_title || $display_description) {
             $form_string .= "\n                        <div class='gform_heading'>";
             if ($display_title) {
                 $form_string .= "\n                            <h3 class='gform_title'>" . $form['title'] . "</h3>";
             }
             if ($display_description) {
                 $form_string .= "\n                            <span class='gform_description'>" . rgar($form, 'description') . "</span>";
             }
             $form_string .= "\n                        </div>";
         }
         $current_page = self::get_current_page($form_id);
         if ($has_pages && !IS_ADMIN) {
             $page_count = self::get_max_page_number($form);
             if ($form["pagination"]["type"] == "percentage") {
                 $form_string .= self::get_progress_bar($form, $form_id, $confirmation_message);
             } else {
                 if ($form["pagination"]["type"] == "steps") {
                     $form_string .= "\n                    <div id='gf_page_steps_{$form_id}' class='gf_page_steps'>";
                     for ($i = 0, $count = sizeof($form["pagination"]["pages"]); $i < $count; $i++) {
                         $step_number = $i + 1;
                         $active_class = $step_number == $current_page ? " gf_step_active" : "";
                         $first_class = $i == 0 ? " gf_step_first" : "";
                         $last_class = $i + 1 == $count ? " gf_step_last" : "";
                         $complete_class = $step_number < $current_page ? " gf_step_completed" : "";
                         $previous_class = $step_number + 1 == $current_page ? " gf_step_previous" : "";
                         $next_class = $step_number - 1 == $current_page ? " gf_step_next" : "";
                         $pending_class = $step_number > $current_page ? " gf_step_pending" : "";
                         $classes = "gf_step" . $active_class . $first_class . $last_class . $complete_class . $previous_class . $next_class . $pending_class;
                         $classes = GFCommon::trim_all($classes);
                         $form_string .= "\n                        <div id='gf_step_{$form_id}_{$step_number}' class='{$classes}'><span class='gf_step_number'>{$step_number}</span>&nbsp;{$form["pagination"]["pages"][$i]}</div>";
                     }
                     $form_string .= "\n                        <div class='gf_step_clear'></div>\n                    </div>";
                 }
             }
         }
         if ($is_postback && !$is_valid) {
             $validation_message = "<div class='validation_error'>" . __("There was a problem with your submission.", "gravityforms") . " " . __("Errors have been highlighted below.", "gravityforms") . "</div>";
             $form_string .= apply_filters("gform_validation_message_{$form["id"]}", apply_filters("gform_validation_message", $validation_message, $form), $form);
         }
         $form_string .= "\n                        <div class='gform_body'>";
         //add first page if this form has any page fields
         if ($has_pages) {
             $style = self::is_page_active($form_id, 1) ? "" : "style='display:none;'";
             $class = !empty($form["firstPageCssClass"]) ? " {$form["firstPageCssClass"]}" : "";
             $form_string .= "<div id='gform_page_{$form_id}_1' class='gform_page{$class}' {$style}>\n                                    <div class='gform_page_fields'>";
         }
         $description_class = rgar($form, "descriptionPlacement") == "above" ? "description_above" : "description_below";
         $form_string .= "\n                            <ul id='gform_fields_{$form_id}' class='gform_fields {$form['labelPlacement']} {$description_class}'>";
         if (is_array($form['fields'])) {
             foreach ($form['fields'] as $field) {
                 $field["conditionalLogicFields"] = self::get_conditional_logic_fields($form, $field["id"]);
                 $form_string .= self::get_field($field, RGFormsModel::get_field_value($field, $field_values), false, $form, $field_values);
             }
         }
         $form_string .= "\n                            </ul>";
         if ($has_pages) {
             $previous_button = self::get_form_button($form["id"], "gform_previous_button_{$form["id"]}", $form["lastPageButton"], __("Previous", "gravityforms"), "button gform_previous_button", __("Previous Page", "gravityforms"), self::get_current_page($form_id) - 1);
             $form_string .= "</div>" . self::gform_footer($form, "gform_page_footer " . $form['labelPlacement'], $ajax, $field_values, $previous_button, $display_title, $display_description, $is_postback) . "\n                            </div>";
             //closes gform_page
         }
         $form_string .= "</div>";
         //closes gform_body
         //suppress form footer for multi-page forms (footer will be included on the last page
         if (!$has_pages) {
             $form_string .= self::gform_footer($form, "gform_footer " . $form['labelPlacement'], $ajax, $field_values, "", $display_title, $display_description, $is_postback);
         }
         $form_string .= "\n                </form>\n                </div>";
         if ($ajax && $is_postback) {
             global $wp_scripts;
             $form_string = "<!DOCTYPE html><html><head>" . "<meta charset='UTF-8' /></head><body class='GF_AJAX_POSTBACK'>" . $form_string . "</body></html>";
         }
         if ($ajax && !$is_postback) {
             $spinner_url = apply_filters("gform_ajax_spinner_url_{$form_id}", apply_filters("gform_ajax_spinner_url", GFCommon::get_base_url() . "/images/spinner.gif", $form), $form);
             $scroll_position = array('default' => '', 'confirmation' => '');
             if ($use_anchor !== false) {
                 $scroll_position['default'] = is_numeric($use_anchor) ? "jQuery(document).scrollTop(" . intval($use_anchor) . ");" : "jQuery(document).scrollTop(jQuery('#gform_wrapper_{$form_id}').offset().top);";
                 $scroll_position['confirmation'] = is_numeric($use_anchor) ? "jQuery(document).scrollTop(" . intval($use_anchor) . ");" : "jQuery(document).scrollTop(jQuery('#gforms_confirmation_message').offset().top);";
             }
             $form_string .= "\n                <iframe style='display:none;width:0px; height:0px;' src='about:blank' name='gform_ajax_frame_{$form_id}' id='gform_ajax_frame_{$form_id}'></iframe>\n                <script type='text/javascript'>" . apply_filters("gform_cdata_open", "") . "" . "function gformInitSpinner_{$form_id}(){" . "jQuery('#gform_{$form_id}').submit(function(){" . "if(jQuery('#gform_ajax_spinner_{$form_id}').length == 0){" . "jQuery('#gform_submit_button_{$form_id}, #gform_wrapper_{$form_id} .gform_previous_button, #gform_wrapper_{$form_id} .gform_next_button, #gform_wrapper_{$form_id} .gform_image_button').attr('disabled', true); " . "jQuery('#gform_submit_button_{$form_id}, #gform_wrapper_{$form_id} .gform_next_button, #gform_wrapper_{$form_id} .gform_image_button').after('<' + 'img id=\"gform_ajax_spinner_{$form_id}\"  class=\"gform_ajax_spinner\" src=\"{$spinner_url}\" alt=\"\" />'); " . "}" . "} );" . "}" . "jQuery(document).ready(function(\$){" . "gformInitSpinner_{$form_id}();" . "jQuery('#gform_ajax_frame_{$form_id}').load( function(){" . "var contents = jQuery(this).contents().find('*').html();" . "var is_postback = contents.indexOf('GF_AJAX_POSTBACK') >= 0;" . "if(!is_postback){return;}" . "var form_content = jQuery(this).contents().find('#gform_wrapper_{$form_id}');" . "var is_redirect = contents.indexOf('gformRedirect(){') >= 0;" . "jQuery('#gform_submit_button_{$form_id}').removeAttr('disabled');" . "var is_form = !(form_content.length <= 0 || is_redirect);" . "if(is_form){" . "jQuery('#gform_wrapper_{$form_id}').html(form_content.html());" . "{$scroll_position['default']}" . "if(window['gformInitDatepicker']) {gformInitDatepicker();}" . "if(window['gformInitPriceFields']) {gformInitPriceFields();}" . "var current_page = jQuery('#gform_source_page_number_{$form_id}').val();" . "gformInitSpinner_{$form_id}();" . "jQuery(document).trigger('gform_page_loaded', [{$form_id}, current_page]);" . "}" . "else if(!is_redirect){" . "var confirmation_content = jQuery(this).contents().find('#gforms_confirmation_message').html();" . "if(!confirmation_content){" . "confirmation_content = contents;" . "}" . "setTimeout(function(){" . "jQuery('#gform_wrapper_{$form_id}').replaceWith('<' + 'div id=\\'gforms_confirmation_message\\' class=\\'gform_confirmation_message_{$form_id}\\'' + '>' + confirmation_content + '<' + '/div' + '>');" . "{$scroll_position['confirmation']}" . "jQuery(document).trigger('gform_confirmation_loaded', [{$form_id}]);" . "}, 50);" . "}" . "else{" . "jQuery('#gform_{$form_id}').append(contents);" . "if(window['gformRedirect']) {gformRedirect();}" . "}" . "jQuery(document).trigger('gform_post_render', [{$form_id}, current_page]);" . "} );" . "} );" . apply_filters("gform_cdata_close", "") . "</script>";
         }
         $is_first_load = !$is_postback;
         if (!$ajax || $is_first_load) {
             self::register_form_init_scripts($form, $field_values);
             if (apply_filters("gform_init_scripts_footer", false)) {
                 add_action("wp_footer", create_function('', 'GFFormDisplay::footer_init_scripts(' . $form['id'] . ');'), 20);
                 add_action("gform_preview_footer", create_function('', 'GFFormDisplay::footer_init_scripts(' . $form['id'] . ');'));
             } else {
                 $form_string .= self::get_form_init_scripts($form);
                 $form_string .= "<script type='text/javascript'>" . apply_filters("gform_cdata_open", "") . " jQuery(document).ready(function(){jQuery(document).trigger('gform_post_render', [{$form_id}, {$current_page}]) } ); " . apply_filters("gform_cdata_close", "") . "</script>";
             }
         }
         return apply_filters('gform_get_form_filter', $form_string);
     } else {
         $progress_confirmation = "";
         //check admin setting for whether the progress bar should start at zero
         $start_at_zero = rgars($form, "pagination/display_progressbar_on_confirmation");
         //check for filter
         $start_at_zero = apply_filters("gform_progressbar_start_at_zero", $start_at_zero, $form);
         //show progress bar on confirmation
         if ($start_at_zero && $has_pages && !IS_ADMIN && ($form["confirmation"]["type"] == "message" && $form["pagination"]["type"] == "percentage") && $form["pagination"]["display_progressbar_on_confirmation"]) {
             $progress_confirmation = self::get_progress_bar($form, $form_id, $confirmation_message);
             if ($ajax) {
                 $progress_confirmation = "<!DOCTYPE html><html><head><meta charset='UTF-8' /></head><body class='GF_AJAX_POSTBACK'>" . $progress_confirmation . $confirmation_message . "</body></html>";
             } else {
                 $progress_confirmation = $progress_confirmation . $confirmation_message;
             }
         } else {
             //return regular confirmation message
             if ($ajax) {
                 $progress_confirmation = "<!DOCTYPE html><html><head><meta charset='UTF-8' /></head><body class='GF_AJAX_POSTBACK'>" . $confirmation_message . "</body></html>";
             } else {
                 $progress_confirmation = $confirmation_message;
             }
         }
         return $progress_confirmation;
     }
 }
 public static function maybe_process_form()
 {
     $form_id = isset($_POST["gform_submit"]) ? $_POST["gform_submit"] : 0;
     if ($form_id) {
         $form_info = RGFormsModel::get_form($form_id);
         $is_valid_form = $form_info && $form_info->is_active;
         if ($is_valid_form) {
             require_once GFCommon::get_base_path() . "/form_display.php";
             GFFormDisplay::process_form($form_id);
         }
     }
 }
Beispiel #7
0
 /**
  * Constructor for class
  *
  * @since 1.0.0
  */
 public function __construct()
 {
     // add admin page
     add_action('admin_menu', array($this, 'add_settings_pages'), 25);
     // save config
     add_action('wp_ajax_frmwks_save_config', array($this, 'save_config'));
     // exporter
     add_action('init', array($this, 'check_exporter'));
     // get forms list
     add_filter('formworks_get_forms', array($this, 'get_forms'));
     add_action('wp_ajax_frmwks_module_data', array($this, 'module_data_loader'));
     if (current_user_can('manage_options')) {
         add_action('wp_ajax_frmwks_rebuild_database', array($this, 'rebuild_database'));
         //add_action( 'wp_ajax_frmwks_reset_form_stats', array( $this, 'reset_form_stats') );
     }
     // create new
     add_action('wp_ajax_frmwks_create_formworks', array($this, 'create_new_formworks'));
     // delete
     add_action('wp_ajax_frmwks_delete_formworks', array($this, 'delete_formworks'));
     add_filter('formworks_stats_field_name', function ($field, $form_prefix, $form_id) {
         switch ($form_prefix) {
             case 'caldera':
                 if (false !== strpos($field, '[')) {
                     $field = strtok($field, '[');
                 }
                 // is CF
                 $form = \Caldera_Forms::get_form($form_id);
                 if (empty($form)) {
                     continue;
                 }
                 if (!empty($form['fields'][$field]['label'])) {
                     $field = $form['fields'][$field]['label'];
                 }
                 break;
             case 'gform':
                 //get gravity form
                 if (!class_exists('RGFormsModel')) {
                     continue;
                 }
                 $form_info = \RGFormsModel::get_form($form_id);
                 break;
             case 'ninja':
                 //get ninja form
                 if (!function_exists('Ninja_Forms')) {
                     continue;
                 }
                 $form_name = Ninja_Forms()->form($form_id)->get_setting('form_title');
                 $form_id = $form_id;
                 break;
             case 'cf7':
                 //get contact form 7
                 if (!class_exists('WPCF7_ContactForm')) {
                     continue;
                 }
                 $cf7form = \WPCF7_ContactForm::get_instance($form_id);
                 $form_name = $cf7form->title();
                 $form_id = $cf7form->id();
                 break;
             case 'frmid':
                 if (!class_exists('FrmForm')) {
                     continue;
                 }
                 $field_id = (int) strtok(str_replace('item_meta[', '', $field), ']');
                 $form_field = \FrmField::getOne($field_id);
                 $field = $form_field->name;
                 if (!empty($form_field->description) && $form_field->description != $form_field->name) {
                     $field .= ':' . $form_field->description;
                 }
                 break;
             case 'jp':
                 $form_post = get_post($form_id);
                 if (empty($form_post)) {
                     continue;
                 }
                 $field = ucwords(str_replace('g' . $form_id . '-', '', $field));
                 break;
             default:
                 //no idea what this is or the form plugin was disabled.
                 break;
         }
         return $field;
     }, 10, 3);
 }
 public static function get_form($form_id, $display_title = true, $display_description = true, $force_display = false, $field_values = null, $ajax = false, $tabindex = 1)
 {
     //looking up form id by form name
     if (!is_numeric($form_id)) {
         $form_id = RGFormsModel::get_form_id($form_id);
     }
     //reading form metadata
     $form = RGFormsModel::get_form_meta($form_id, true);
     $form = RGFormsModel::add_default_properties($form);
     //disable ajax if form has a reCAPTCHA field (not supported).
     if ($ajax && self::has_recaptcha_field($form)) {
         $ajax = false;
     }
     $is_postback = false;
     $is_valid = true;
     $confirmation_message = "";
     $page_number = 1;
     //If form was submitted, read variables set during form submission procedure
     $submission_info = isset(self::$submission[$form_id]) ? self::$submission[$form_id] : false;
     if ($submission_info) {
         $is_postback = true;
         $is_valid = $submission_info["is_valid"] || rgget("is_confirmation", $submission_info);
         $form = $submission_info["form"];
         $lead = $submission_info["lead"];
         $confirmation_message = rgget("confirmation_message", $submission_info);
         if ($is_valid && !RGForms::get("is_confirmation", $submission_info)) {
             if ($submission_info["page_number"] == 0) {
                 //post submission hook
                 do_action("gform_post_submission", $lead, $form);
                 do_action("gform_post_submission_{$form["id"]}", $lead, $form);
             } else {
                 //change page hook
                 do_action("gform_post_paging", $form, $submission_info["source_page_number"], $submission_info["page_number"]);
                 do_action("gform_post_paging_{$form["id"]}", $form, $submission_info["source_page_number"], $submission_info["page_number"]);
             }
         }
     } else {
         if (!current_user_can("administrator")) {
             RGFormsModel::insert_form_view($form_id, $_SERVER['REMOTE_ADDR']);
         }
     }
     if (rgar($form, "enableHoneypot")) {
         $form["fields"][] = self::get_honeypot_field($form);
     }
     //Fired right before the form rendering process. Allow users to manipulate the form object before it gets displayed in the front end
     $form = apply_filters("gform_pre_render_{$form_id}", apply_filters("gform_pre_render", $form));
     if ($form == null) {
         return "<p>" . __("Oops! We could not locate your form.", "gravityforms") . "</p>";
     }
     $has_pages = self::has_pages($form);
     //calling tab index filter
     GFCommon::$tab_index = apply_filters("gform_tabindex_{$form_id}", apply_filters("gform_tabindex", $tabindex, $form), $form);
     //Don't display inactive forms
     if (!$force_display && !$is_postback) {
         $form_info = RGFormsModel::get_form($form_id);
         if (!$form_info->is_active) {
             return "";
         }
         //If form has a schedule, make sure it is within the configured start and end dates
         if (rgar($form, "scheduleForm")) {
             $local_time_start = sprintf("%s %02d:%02d %s", $form["scheduleStart"], $form["scheduleStartHour"], $form["scheduleStartMinute"], $form["scheduleStartAmpm"]);
             $local_time_end = sprintf("%s %02d:%02d %s", $form["scheduleEnd"], $form["scheduleEndHour"], $form["scheduleEndMinute"], $form["scheduleEndAmpm"]);
             $timestamp_start = strtotime($local_time_start . ' +0000');
             $timestamp_end = strtotime($local_time_end . ' +0000');
             $now = current_time("timestamp");
             if (!empty($form["scheduleStart"]) && $now < $timestamp_start || !empty($form["scheduleEnd"]) && $now > $timestamp_end) {
                 return empty($form["scheduleMessage"]) ? "<p>" . __("Sorry. This form is no longer available.", "gravityforms") . "</p>" : "<p>" . GFCommon::gform_do_shortcode($form["scheduleMessage"]) . "</p>";
             }
         }
         //If form has a limit of entries, check current entry count
         if (rgar($form, "limitEntries")) {
             $period = rgar($form, "limitEntriesPeriod");
             $range = self::get_limit_period_dates($period);
             $entry_count = RGFormsModel::get_lead_count($form_id, "", null, null, $range["start_date"], $range["end_date"]);
             if ($entry_count >= $form["limitEntriesCount"]) {
                 return empty($form["limitEntriesMessage"]) ? "<p>" . __("Sorry. This form is no longer accepting new submissions.", "gravityforms") . "</p>" : "<p>" . GFCommon::gform_do_shortcode($form["limitEntriesMessage"]) . "</p>";
             }
         }
         // If form requires login, check if user is logged in
         if (rgar($form, "requireLogin")) {
             if (!is_user_logged_in()) {
                 return empty($form["requireLoginMessage"]) ? "<p>" . __("Sorry. You must be logged in to view this form.", "gravityforms") . "</p>" : "<p>" . GFCommon::gform_do_shortcode($form["requireLoginMessage"]) . "</p>";
             }
         }
     }
     $form_string = "";
     //When called via a template, this will enqueue the proper scripts
     //When called via a shortcode, this will be ignored (too late to enqueue), but the scripts will be enqueued via the enqueue_scripts event
     self::enqueue_form_scripts($form, $ajax);
     if (empty($confirmation_message)) {
         $wrapper_css_class = GFCommon::get_browser_class() . " gform_wrapper";
         if (!$is_valid) {
             $wrapper_css_class .= " gform_validation_error";
         }
         //Hidding entire form if conditional logic is on to prevent "hidden" fields from blinking. Form will be set to visible in the conditional_logic.php after the rules have been applied.
         $style = self::has_conditional_logic($form) ? "style='display:none'" : "";
         $form_string .= "\n                <div class='{$wrapper_css_class}' id='gform_wrapper_{$form_id}' " . $style . ">";
         $action = add_query_arg(array());
         $default_anchor = $has_pages || $ajax ? true : false;
         $use_anchor = apply_filters("gform_confirmation_anchor_{$form["id"]}", apply_filters("gform_confirmation_anchor", $default_anchor));
         if ($use_anchor !== false) {
             $form_string .= "<a name='gf_{$form_id}' class='gform_anchor' ></a>";
             $action .= "#gf_{$form_id}";
         }
         $target = $ajax ? "target='gform_ajax_frame_{$form_id}'" : "";
         $form_css_class = !empty($form["cssClass"]) ? "class='{$form["cssClass"]}'" : "";
         $action = esc_attr($action);
         $form_string .= apply_filters("gform_form_tag_{$form_id}", apply_filters("gform_form_tag", "<form method='post' enctype='multipart/form-data' {$target} id='gform_{$form_id}' {$form_css_class} action='{$action}'>", $form), $form);
         if ($display_title || $display_description) {
             $form_string .= "\n                        <div class='gform_heading'>";
             if ($display_title) {
                 $form_string .= "\n                            <h3 class='gform_title'>" . $form['title'] . "</h3>";
             }
             if ($display_description) {
                 $form_string .= "\n                            <span class='gform_description'>" . rgar($form, 'description') . "</span>";
             }
             $form_string .= "\n                        </div>";
         }
         if ($has_pages && !IS_ADMIN) {
             $page_count = self::get_max_page_number($form);
             $current_page = self::get_current_page($form_id);
             if ($form["pagination"]["type"] == "percentage") {
                 $percent = floor($current_page / $page_count * 100) . "%";
                 $page_name = rgar(rgar($form["pagination"], "pages"), $current_page - 1);
                 $page_name = !empty($page_name) ? " - " . $page_name : "";
                 $style = $form["pagination"]["style"];
                 $color = $style == "custom" ? " color:{$form["pagination"]["color"]};" : "";
                 $bgcolor = $style == "custom" ? " background-color:{$form["pagination"]["backgroundColor"]};" : "";
                 $form_string .= "\n                        <div id='gf_progressbar_wrapper_{$form_id}' class='gf_progressbar_wrapper'>\n                            <h3 class='gf_progressbar_title'>" . __("Step", "gravityforms") . " {$current_page} " . __("of", "gravityforms") . " {$page_count}{$page_name}</h3>\n                            <div class='gf_progressbar'>\n                                <div class='gf_progressbar_percentage percentbar_{$style}' style='width:{$percent};{$color}{$bgcolor}'><span>{$percent}</span></div>\n                            </div>\n                        </div>";
             } else {
                 if ($form["pagination"]["type"] == "steps") {
                     $form_string .= "\n                    <div id='gf_page_steps_{$form_id}' class='gf_page_steps'>";
                     for ($i = 0, $count = sizeof($form["pagination"]["pages"]); $i < $count; $i++) {
                         $step_number = $i + 1;
                         $active_class = $step_number == $current_page ? " gf_step_active" : "";
                         $first_class = $i == 0 ? " gf_step_first" : "";
                         $last_class = $i + 1 == $count ? " gf_step_last" : "";
                         $complete_class = $step_number < $current_page ? " gf_step_completed" : "";
                         $previous_class = $step_number + 1 == $current_page ? " gf_step_previous" : "";
                         $next_class = $step_number - 1 == $current_page ? " gf_step_next" : "";
                         $pending_class = $step_number > $current_page ? " gf_step_pending" : "";
                         $classes = "gf_step" . $active_class . $first_class . $last_class . $complete_class . $previous_class . $next_class . $pending_class;
                         $classes = GFCommon::trim_all($classes);
                         $form_string .= "\n                        <div id='gf_step_{$form_id}_{$step_number}' class='{$classes}'><span class='gf_step_number'>{$step_number}</span>&nbsp;{$form["pagination"]["pages"][$i]}</div>";
                     }
                     $form_string .= "\n                        <div class='gf_step_clear'></div>\n                    </div>";
                 }
             }
         }
         if ($is_postback && !$is_valid) {
             $validation_message = "<div class='validation_error'>" . __("There was a problem with your submission.", "gravityforms") . " " . __("Errors have been highlighted below.", "gravityforms") . "</div>";
             $form_string .= apply_filters("gform_validation_message_{$form["id"]}", apply_filters("gform_validation_message", $validation_message, $form), $form);
         }
         $form_string .= "\n                        <div class='gform_body'>";
         //add first page if this form has any page fields
         if ($has_pages) {
             $style = self::is_page_active($form_id, 1) ? "" : "style='display:none;'";
             $class = !empty($form["firstPageCssClass"]) ? " {$form["firstPageCssClass"]}" : "";
             $form_string .= "<div id='gform_page_{$form_id}_1' class='gform_page{$class}' {$style}>\n                                    <div class='gform_page_fields'>";
         }
         $description_class = rgar($form, "descriptionPlacement") == "above" ? "description_above" : "description_below";
         $form_string .= "\n                            <ul id='gform_fields_{$form_id}' class='gform_fields {$form['labelPlacement']} {$description_class}'>";
         if (is_array($form['fields'])) {
             foreach ($form['fields'] as $field) {
                 $field["conditionalLogicFields"] = self::get_conditional_logic_fields($form, $field["id"]);
                 $form_string .= self::get_field($field, RGFormsModel::get_field_value($field, $field_values), false, $form, $field_values);
             }
         }
         $form_string .= "\n                            </ul>";
         if ($has_pages) {
             $previous_button = self::get_form_button($form["id"], "gform_previous_button_{$form["id"]}", $form["lastPageButton"], __("Previous", "gravityforms"), "button gform_previous_button", __("Previous Page", "gravityforms"), self::get_current_page($form_id) - 1);
             $form_string .= "</div>" . self::gform_footer($form, "gform_page_footer " . $form['labelPlacement'], $ajax, $field_values, $previous_button, $display_title, $display_description, $is_postback) . "\n                            </div>";
             //closes gform_page
         }
         $form_string .= "</div>";
         //closes gform_body
         //suppress form footer for multi-page forms (footer will be included on the last page
         if (!$has_pages) {
             $form_string .= self::gform_footer($form, "gform_footer " . $form['labelPlacement'], $ajax, $field_values, "", $display_title, $display_description, $is_postback);
         }
         $form_string .= "\n                </form>\n                </div>";
         //adding conditional logic script if conditional logic is configured for this form.
         //get_conditional_logic also adds the chosen script for the enhanced dropdown option.
         //if this form does not have conditional logic, add chosen script separately
         if (self::has_conditional_logic($form)) {
             $form_string .= self::get_conditional_logic($form);
         } else {
             if (self::has_enhanced_dropdown($form)) {
                 $form_string .= "<script type='text/javascript'>//<![CDATA[\n" . self::get_chosen_init_script($form) . "\n//]]></script>";
             }
         }
         //adding currency config if there are any product fields in the form
         if (self::has_price_field($form)) {
             if (!class_exists("RGCurrency")) {
                 require_once "currency.php";
             }
             $form_string .= "<script type='text/javascript'>//<![CDATA[\n if(window[\"gformInitPriceFields\"]) jQuery(document).ready(function(){gformInitPriceFields();}); window['gf_currency_config'] = " . GFCommon::json_encode(RGCurrency::get_currency(GFCommon::get_currency())) . "; \n//]]></script>";
         }
         if (self::has_password_strength($form)) {
             $form_string .= "<script type='text/javascript'>//<![CDATA[\nif(!window['gf_text']){window['gf_text'] = new Array();} window['gf_text']['password_blank'] = '" . __("Strength indicator", "gravityforms") . "'; window['gf_text']['password_mismatch'] = '" . __("Mismatch", "gravityforms") . "';window['gf_text']['password_bad'] = '" . __("Bad", "gravityforms") . "'; window['gf_text']['password_short'] = '" . __("Short", "gravityforms") . "'; window['gf_text']['password_good'] = '" . __("Good", "gravityforms") . "'; window['gf_text']['password_strong'] = '" . __("Strong", "gravityforms") . "';\n//]]></script>";
         }
         if (GFCommon::has_credit_card_field($form)) {
             $card_rules = self::get_credit_card_rules();
             $form_string .= "<script type='text/javascript'>//<![CDATA[\n if(!window['gf_cc_rules']){window['gf_cc_rules'] = new Array(); } window['gf_cc_rules'] = " . GFCommon::json_encode($card_rules) . "; \n//]]></script>";
         }
         if ($ajax && $is_postback) {
             global $wp_scripts;
             $form_string = "<!DOCTYPE html><html><head>" . "<script type='text/javascript' src='" . $wp_scripts->base_url . $wp_scripts->registered["jquery"]->src . "'></script>" . "<script type='text/javascript' src='" . GFCommon::get_base_url() . "/js/conditional_logic.js'></script>" . "<meta charset='UTF-8' /></head><body>" . $form_string . "</body></html>";
         }
         if ($ajax && !$is_postback) {
             $spinner_url = apply_filters("gform_ajax_spinner_url_{$form_id}", apply_filters("gform_ajax_spinner_url", GFCommon::get_base_url() . "/images/spinner.gif", $form), $form);
             $scroll_position = array('default' => '', 'confirmation' => '');
             if ($use_anchor !== false) {
                 $scroll_position['default'] = is_numeric($use_anchor) ? "jQuery(document).scrollTop(" . intval($use_anchor) . ");" : "jQuery(document).scrollTop(jQuery('#gform_wrapper_{$form_id}').offset().top);";
                 $scroll_position['confirmation'] = is_numeric($use_anchor) ? "jQuery(document).scrollTop(" . intval($use_anchor) . ");" : "jQuery(document).scrollTop(jQuery('#gforms_confirmation_message').offset().top);";
             }
             $form_string .= "\n                <iframe style='display:none;width:0px; height:0px;' src='about:blank' name='gform_ajax_frame_{$form_id}' id='gform_ajax_frame_{$form_id}'></iframe>\n                <script type='text/javascript'>//<![CDATA[\n" . "function gformInitSpinner(){" . "jQuery('#gform_{$form_id}').submit(function(){" . "jQuery('#gform_submit_button_{$form_id}').attr('disabled', true).after('<' + 'img id=\"gform_ajax_spinner_{$form_id}\"  class=\"gform_ajax_spinner\" src=\"{$spinner_url}\" alt=\"\" />');" . "jQuery('#gform_wrapper_{$form_id} .gform_previous_button').attr('disabled', true); " . "jQuery('#gform_wrapper_{$form_id} .gform_next_button').attr('disabled', true).after('<' + 'img id=\"gform_ajax_spinner_{$form_id}\"  class=\"gform_ajax_spinner\" src=\"{$spinner_url}\" alt=\"\" />');" . "});" . "}" . "jQuery(document).ready(function(\$){" . "gformInitSpinner();" . "jQuery('#gform_ajax_frame_{$form_id}').load( function(){" . "var form_content = jQuery(this).contents().find('#gform_wrapper_{$form_id}');" . "var confirmation_content = jQuery(this).contents().find('#gforms_confirmation_message');" . "jQuery('#gform_submit_button_{$form_id}').removeAttr('disabled');" . "if(form_content.length > 0){" . "jQuery('#gform_wrapper_{$form_id}').html(form_content.html());" . "{$scroll_position['default']}" . "if(window['gformInitDatepicker']) {gformInitDatepicker();}" . "if(window['gformInitPriceFields']) {gformInitPriceFields();}" . "var current_page = jQuery('#gform_source_page_number_{$form_id}').val();" . "gformInitSpinner();" . "jQuery(document).trigger('gform_page_loaded', [{$form_id}, current_page]);" . "}" . "else if(confirmation_content.length > 0){" . "setTimeout(function(){" . "jQuery('#gform_wrapper_{$form_id}').replaceWith('<' + 'div id=\\'gforms_confirmation_message\\' class=\\'gform_confirmation_message_{$form_id}\\'' + '>' + confirmation_content.html() + '<' + '/div' + '>');" . "{$scroll_position['confirmation']}" . "jQuery(document).trigger('gform_confirmation_loaded', [{$form_id}]);" . "}, 50);" . "}" . "else{" . "jQuery('#gform_{$form_id}').append(jQuery(this).contents().find('*').html());" . "if(window['gformRedirect']) gformRedirect();" . "}" . "jQuery(document).trigger('gform_post_render', [{$form_id}, current_page]);" . "});" . "});" . "\n//]]></script>";
         }
         return apply_filters('gform_get_form_filter', $form_string);
     } else {
         if ($ajax) {
             $confirmation_message = "<!DOCTYPE html><html><head><meta charset='UTF-8' /></head><body>" . $confirmation_message . "</body></html>";
         }
         return $confirmation_message;
     }
 }
 <?php 
        _e("\\'Cancel\\' to stop, \\'OK\\' to delete.", "templatemerge");
        ?>
')){ DeleteSetting(<?php 
        echo $tags[$i]["id"];
        ?>
);}"><?php 
        _e("Delete", "templatemerge");
        ?>
</a>
                                            </span>
                                        </div>
                                    </td>
                                    <td class="column-date">
                                    	<?php 
        $data = RGFormsModel::get_form($tags[$i]["form_id"]);
        echo $data->title;
        ?>
                                    </td>
                                    <td class="column-date">
                                        <?php 
        $field_name = TemplateData::get_field_name($tags[$i]["form_id"], $tags[$i]["form_field"]);
        echo $field_name;
        ?>
                                    </td>
                                </tr>
                                <?php 
        $i++;
    }
} else {
    ?>
 public static function get_form($form_id, $display_title = true, $display_description = true, $force_display = false, $field_values = null, $ajax = false, $tabindex = 1)
 {
     //		echo  "$form_id, $display_title = true, $display_description = true, $force_display = false, $field_values = null, $ajax = false, $tabindex = 1 ";
     /**
      * @To do tomorrow
      * datact if its approved or not => done
      * Lacking will find the correct container and hide it.
      * /app/wwwroot/wp-content/plugins/gravityforms/includes/fields/class-gf-field-creditcard.php
      * /app/wwwroot/wp-content/themes/TPO10/functions.php
      * /app/wwwroot/wp-content/plugins/gravityforms/form_display
      */
     /**
      * STEPS
      *
      * Find way how to filter if approved or not => done
      * Find the actual html of the credit cards fields
      */
     // gform_lead_id = 1137
     // [gform_edit_id] => 1137
     // [input_id] => 1137
     // [input_payment_status] => approved
     //EDIT
     // gform_edit_id = 1137
     // input_id = 1137
     // [input_form_id] => 75
     // [input_payment_status] => approved
     // [gform_submit] => 75
     //IF CLICK NEXT
     /**
      * [gform_lead_id] => 1137
      * GET DATA BY THAT ID CHECK IF APPROVED OR NOT APPROVED
      */
     //IF EDIT
     /**
      * [input_payment_status] => approved
      * [input_id] => 1137
      * [gform_edit_id] => 1137
      * [input_form_id] => 75
      */
     //		print_r($_POST);
     //		echo "total post " . count($_POST) . '<br>';
     //		if (count($_POST) > 1) {
     //
     //			$form_id_lead = $_POST['gform_edit_id'];
     //			$form_id = $_POST['input_form_id'];
     //			if (empty($form_id_lead)) {
     //				$form_id_lead = $_POST['gform_lead_id'];
     //			}
     //			if (empty($form_id)) {
     //				$form_id = $_POST['gform_submit'];
     //			}
     //
     //			$paymentStatus = '';
     //			$isApproved = false;
     //			if (!empty($form_id) and !empty($form_id_lead)) {
     //				//				echo "form id is not empty <br>";
     //				global $wpdb;
     //				$results = $wpdb->get_results("SELECT * FROM wp_rg_lead WHERE form_id = $form_id AND id = $form_id_lead", 'ARRAY_A');
     //
     //				//				echo "<pre>";
     //				//				echo "result from db";
     //				//				print_r($results);
     //				//
     //				//				echo "result from post";
     //				//				print_r($_POST);
     //				//
     //				//				echo "</pre>";
     //				// echo "This is the form printed <br> form id " . $form_id;
     //				// provides the ability to modify the options used to display the form
     //
     //
     //
     //				if ($_POST['input_payment_status'] == 'approved' || $_POST['input_payment_status'] == 'approve' || $_POST['input_payment_status'] == 'Approved') {
     //					//echo "approved<br>";
     //					//add code to hide credit card
     //					$isApproved = true;
     //					$paymentStatus = $_POST['input_payment_status'];
     //
     //				}
     //				if ($results[0]['payment_status'] == 'approved' || $results[0]['payment_status'] == 'approve' || $results[0]['payment_status'] == 'Approved') {
     //					//echo "approved<br>";
     //					//add code to hide credit card
     //					$isApproved = true;
     //					$paymentStatus = $results[0]['payment_status'];
     //				} else {
     //					//do nothing
     //					// echo "not approved<br>";
     //				}
     //
     //				// echo "form id " . $form_id . '<br>';
     //				// echo "lead id " . $form_id_lead . '<br>';
     //				// echo "status " . $results[0]['payment_status'] . '<br>';
     //
     //				// echo "db status = " . $results[0][0]['payment_status'] . '<br>';
     //				// echo "form id " . $form_id . '<br>';
     //				// cho "lead id " . $form_id_lead . '<br>';
     //
     //			} else {
     //				// echo "form id is  empty <br>";
     //			}  // end if
     //		} //end if form
     /**
      * Get the value for the wp_users.user_status
      * and set the if user type is member or none member
      * if member then hide credit card if not then show credit card
      */
     //        global $current_user;
     //        if($current_user->user_status == 0) {
     //            $userType = 'none member';
     //        } else {
     //            $userType = 'member';
     //        }
     /**
      * Another option above but prefer for above code because it's short
      * Set it to true when when you want to use it.
      * same function to above code.
      */
     if (false) {
         global $wpdb;
         $user_ID = get_current_user_id();
         $userInfo = $wpdb->get_results("SELECT * FROM wp_users WHERE ID = " . $user_ID, 'ARRAY_A');
         if ($userInfo[0]['user_status'] == 0) {
             $userType = 'none member';
         } else {
             $userType = 'member';
         }
     }
     // $currentUserInfo = get_currentuserinfo();
     //echo "<pre>";
     // print_r($userInfo);
     //print_r($currentUserInfo);
     //echo "id " . $current_user->user_status;
     //echo "</pre>";
     //echo "user status " . $current_user->user_status;
     // exit;
     /**
      * Original code from this plugin
      */
     $form_args = apply_filters('gform_form_args', compact('form_id', 'display_title', 'display_description', 'force_display', 'field_values', 'ajax', 'tabindex'));
     extract($form_args);
     //looking up form id by form name
     if (!is_numeric($form_id)) {
         $form_id = RGFormsModel::get_form_id($form_id);
     }
     //reading form metadata
     //check code line
     $form = RGFormsModel::get_form_meta($form_id, true);
     // echo "<pre>";
     // print_r($form);
     //echo "<pre>";
     // echo 'title ' . $form['title'] . '<br>';
     // echo 'desc ' . $form['description'] . '<br>';
     // echo 'fields <br>';
     // print( $form['fields'] );
     // $fields_array  =  (array) $form['fields'];
     // echo "<pre>";
     // print_r($fields_array);
     // echo "</pre>";
     // echo "feld " . $fields_array[0]->type . '<br>';
     // exit;
     $action = remove_query_arg('gf_token');
     //disable ajax if form has a reCAPTCHA field (not supported).
     if ($ajax && self::has_recaptcha_field($form)) {
         $ajax = false;
     }
     if (isset($_POST['gform_send_resume_link'])) {
         $save_email_confirmation = self::handle_save_email_confirmation($form, $ajax);
         if (is_wp_error($save_email_confirmation)) {
             // Failed email validation
             $resume_token = rgpost('gform_resume_token');
             $incomplete_submission_info = GFFormsModel::get_incomplete_submission_values(rgpost('gform_resume_token'));
             if ($incomplete_submission_info['form_id'] == $form_id) {
                 $submission_details_json = $incomplete_submission_info['submission'];
                 $submission_details = json_decode($submission_details_json, true);
                 $partial_entry = $submission_details['partial_entry'];
                 $form = self::update_confirmation($form, $partial_entry, 'form_saved');
                 $confirmation_message = rgar($form['confirmation'], 'message');
                 $nl2br = rgar($form['confirmation'], 'disableAutoformat') ? false : true;
                 $confirmation_message = GFCommon::replace_variables($confirmation_message, $form, $partial_entry, false, true, $nl2br);
                 return self::handle_save_confirmation($form, $resume_token, $confirmation_message, $ajax);
             }
         } else {
             return $save_email_confirmation;
         }
     }
     $is_postback = false;
     $is_valid = true;
     $confirmation_message = '';
     //If form was submitted, read variables set during form submission procedure
     $submission_info = isset(self::$submission[$form_id]) ? self::$submission[$form_id] : false;
     if (rgar($submission_info, 'saved_for_later') == true) {
         $resume_token = $submission_info['resume_token'];
         $confirmation_message = rgar($submission_info, 'confirmation_message');
         return self::handle_save_confirmation($form, $resume_token, $confirmation_message, $ajax);
     }
     $partial_entry = $submitted_values = false;
     if (isset($_GET['gf_token'])) {
         $incomplete_submission_info = GFFormsModel::get_incomplete_submission_values($_GET['gf_token']);
         if ($incomplete_submission_info['form_id'] == $form_id) {
             $submission_details_json = $incomplete_submission_info['submission'];
             $submission_details = json_decode($submission_details_json, true);
             $partial_entry = $submission_details['partial_entry'];
             $submitted_values = $submission_details['submitted_values'];
             $field_values = $submission_details['field_values'];
             GFFormsModel::$unique_ids[$form_id] = $submission_details['gform_unique_id'];
             GFFormsModel::$uploaded_files[$form_id] = $submission_details['files'];
             self::set_submission_if_null($form_id, 'resuming_incomplete_submission', true);
             self::set_submission_if_null($form_id, 'form_id', $form_id);
             self::set_submission_if_null($form_id, 'page_number', $submission_details['page_number']);
         }
     }
     if (!is_array($partial_entry)) {
         $view_counter_disabled = gf_apply_filters('gform_disable_view_counter', $form_id, false);
         if ($submission_info) {
             $is_postback = true;
             $is_valid = rgar($submission_info, 'is_valid') || rgar($submission_info, 'is_confirmation');
             $form = $submission_info['form'];
             $lead = $submission_info['lead'];
             $confirmation_message = rgget('confirmation_message', $submission_info);
             if ($is_valid && !RGForms::get('is_confirmation', $submission_info)) {
                 if ($submission_info['page_number'] == 0) {
                     //post submission hook
                     gf_do_action('gform_post_submission', $form['id'], $lead, $form);
                 } else {
                     //change page hook
                     gf_do_action('gform_post_paging', $form['id'], $form, $submission_info['source_page_number'], $submission_info['page_number']);
                 }
             }
         } elseif (!current_user_can('administrator') && !$view_counter_disabled) {
             RGFormsModel::insert_form_view($form_id, $_SERVER['REMOTE_ADDR']);
         }
     }
     if (rgar($form, 'enableHoneypot')) {
         $form['fields'][] = self::get_honeypot_field($form);
     }
     // print test
     // echo " submition id " . $form['id'] . '<br>';
     //Fired right before the form rendering process. Allow users to manipulate the form object before it gets displayed in the front end
     //check this part
     $form = gf_apply_filters('gform_pre_render', $form_id, $form, $ajax, $field_values);
     // echo "<pre>";
     //
     // print_r($form);
     //
     // echo "<pre>";
     if ($form == null) {
         return '<p>' . esc_html__('Oops! We could not locate your form.', 'gravityforms') . '</p>';
     }
     $has_pages = self::has_pages($form);
     //calling tab index filter
     GFCommon::$tab_index = gf_apply_filters('gform_tabindex', $form_id, $tabindex, $form);
     //Don't display inactive forms
     if (!$force_display && !$is_postback) {
         //check here..
         $form_info = RGFormsModel::get_form($form_id);
         if (empty($form_info) || !$form_info->is_active) {
             return '';
         }
         // If form requires login, check if user is logged in
         if (rgar($form, 'requireLogin')) {
             if (!is_user_logged_in()) {
                 return empty($form['requireLoginMessage']) ? '<p>' . esc_html__('Sorry. You must be logged in to view this form.', 'gravityforms') . '</p>' : '<p>' . GFCommon::gform_do_shortcode($form['requireLoginMessage']) . '</p>';
             }
         }
     }
     // show the form regardless of the following validations when force display is set to true
     if (!$force_display || $is_postback) {
         $form_schedule_validation = self::validate_form_schedule($form);
         // if form schedule validation fails AND this is not a postback, display the validation error
         // if form schedule validation fails AND this is a postback, make sure is not a valid submission (enables display of confirmation message)
         if ($form_schedule_validation && !$is_postback || $form_schedule_validation && $is_postback && !$is_valid) {
             return $form_schedule_validation;
         }
         $entry_limit_validation = self::validate_entry_limit($form);
         // refer to form schedule condition notes above
         if ($entry_limit_validation && !$is_postback || $entry_limit_validation && $is_postback && !$is_valid) {
             return $entry_limit_validation;
         }
     }
     $form_string = '';
     //When called via a template, this will enqueue the proper scripts
     //When called via a shortcode, this will be ignored (too late to enqueue), but the scripts will be enqueued via the enqueue_scripts event
     self::enqueue_form_scripts($form, $ajax);
     $is_form_editor = GFCommon::is_form_editor();
     $is_entry_detail = GFCommon::is_entry_detail();
     $is_admin = $is_form_editor || $is_entry_detail;
     if (empty($confirmation_message)) {
         $wrapper_css_class = GFCommon::get_browser_class() . ' gform_wrapper';
         if (!$is_valid) {
             $wrapper_css_class .= ' gform_validation_error';
         }
         //Hiding entire form if conditional logic is on to prevent 'hidden' fields from blinking. Form will be set to visible in the conditional_logic.php after the rules have been applied.
         $style = self::has_conditional_logic($form) ? "style='display:none'" : '';
         $custom_wrapper_css_class = !empty($form['cssClass']) ? " {$form['cssClass']}_wrapper" : '';
         $form_string .= "\n                <div class='{$wrapper_css_class}{$custom_wrapper_css_class}' id='gform_wrapper_{$form_id}' " . $style . '>';
         $default_anchor = $has_pages || $ajax ? true : false;
         $use_anchor = gf_apply_filters('gform_confirmation_anchor', $form_id, $default_anchor);
         if ($use_anchor !== false) {
             $form_string .= "<a id='gf_{$form_id}' name='gf_{$form_id}' class='gform_anchor' ></a>";
             $action .= "#gf_{$form_id}";
         }
         $target = $ajax ? "target='gform_ajax_frame_{$form_id}'" : '';
         $form_css_class = !empty($form['cssClass']) ? "class='{$form['cssClass']}'" : '';
         $action = esc_url($action);
         $form_string .= gf_apply_filters('gform_form_tag', $form_id, "<form method='post' enctype='multipart/form-data' {$target} id='gform_{$form_id}' {$form_css_class} action='{$action}'>", $form);
         if ($display_title || $display_description) {
             $form_string .= "\n                        <div class='gform_heading'>";
             if ($display_title) {
                 $form_string .= "\n                            <h3 class='gform_title'>" . $form['title'] . '</h3>';
             }
             if ($display_description) {
                 $form_string .= "\n                            <span class='gform_description'>" . rgar($form, 'description') . '</span>';
             }
             $form_string .= '
                     </div>';
         }
         $current_page = self::get_current_page($form_id);
         if ($has_pages && !$is_admin) {
             if ($form['pagination']['type'] == 'percentage') {
                 $form_string .= self::get_progress_bar($form, $form_id, $confirmation_message);
             } else {
                 if ($form['pagination']['type'] == 'steps') {
                     $form_string .= "\n                    <div id='gf_page_steps_{$form_id}' class='gf_page_steps'>";
                     $pages = isset($form['pagination']['pages']) ? $form['pagination']['pages'] : array();
                     for ($i = 0, $count = sizeof($pages); $i < $count; $i++) {
                         $step_number = $i + 1;
                         $active_class = $step_number == $current_page ? ' gf_step_active' : '';
                         $first_class = $i == 0 ? ' gf_step_first' : '';
                         $last_class = $i + 1 == $count ? ' gf_step_last' : '';
                         $complete_class = $step_number < $current_page ? ' gf_step_completed' : '';
                         $previous_class = $step_number + 1 == $current_page ? ' gf_step_previous' : '';
                         $next_class = $step_number - 1 == $current_page ? ' gf_step_next' : '';
                         $pending_class = $step_number > $current_page ? ' gf_step_pending' : '';
                         $classes = 'gf_step' . $active_class . $first_class . $last_class . $complete_class . $previous_class . $next_class . $pending_class;
                         $classes = GFCommon::trim_all($classes);
                         $form_string .= "\n                        <div id='gf_step_{$form_id}_{$step_number}' class='{$classes}'><span class='gf_step_number'>{$step_number}</span>&nbsp;<span class='gf_step_label'>{$pages[$i]}</span></div>";
                     }
                     $form_string .= "\n                        <div class='gf_step_clear'></div>\n                    </div>";
                 }
             }
         }
         if ($is_postback && !$is_valid) {
             $validation_message = "<div class='validation_error'>" . esc_html__('There was a problem with your submission.', 'gravityforms') . ' ' . esc_html__('Errors have been highlighted below.', 'gravityforms') . '</div>';
             $form_string .= gf_apply_filters('gform_validation_message', $form_id, $validation_message, $form);
         }
         $form_string .= "\n                        <div class='gform_body'>";
         //add first page if this form has any page fields
         if ($has_pages) {
             $style = self::is_page_active($form_id, 1) ? '' : "style='display:none;'";
             $class = !empty($form['firstPageCssClass']) ? " {$form['firstPageCssClass']}" : '';
             $form_string .= "<div id='gform_page_{$form_id}_1' class='gform_page{$class}' {$style}>\n                                    <div class='gform_page_fields'>";
         }
         $description_class = rgar($form, 'descriptionPlacement') == 'above' ? 'description_above' : 'description_below';
         $sublabel_class = rgar($form, 'subLabelPlacement') == 'above' ? 'form_sublabel_above' : 'form_sublabel_below';
         $form_string .= "<ul id='gform_fields_{$form_id}' class='" . GFCommon::get_ul_classes($form) . "'>";
         /**
          * Here the field is being filtered
          * So if detect credit card then no credit card will show.
          *
          * Documentation:
          *
          * 1.) DB:
          * - tpocom_dash.wp_rg_lead.payment_status = "approved" or NULL
          *
          * 2.) Form.Hidden Field:
          * - Field Label: "payment status"
          * - Parameter Name: "payment_status_value"
          *
          * 3.) Form.Credit Card:
          * - Advance
          * - Enable condition logic "Hide" this field "all" of the following match "payment status" is "approved"
          */
         /**
          * @var $paymentStatus - will hold the variable if approved or not approved.
          * It is declared first line of this function, you can see the condition there.
          *
          * @var $field->inputName - set to "payment_status_value" <- this is the parameter name.
          * that's the string we set the setting up the form in the GUI at admin area.
          */
         /**
          * @var userType = member or none member
          */
         // $userType = 'member';
         // $paymentStatus = 'approved';
         // $userType = 'member';
         // get membership type
         // get payment status
         $paymentStatus = self::getPaymentStatus($form);
         $memberShipStatus = self::getMembershipStatus();
         $fieldValue = self::filterPaymentAndMemberShip($paymentStatus, $memberShipStatus);
         //			 echo "payment status $paymentStatus membership status $memberShipStatus field value = $fieldValue <br>";
         if (is_array($form['fields'])) {
             $counter = 0;
             foreach ($form['fields'] as $field) {
                 /**
                  * Hide through form condition
                  */
                 if ($field->inputName == 'member_type_value') {
                     $form_string .= self::get_field($field, $fieldValue, false, $form, $field_values);
                 } else {
                     $field->conditionalLogicFields = self::get_conditional_logic_fields($form, $field->id);
                     if (is_array($submitted_values)) {
                         $field_value = $submitted_values[$field->id];
                     } else {
                         $field_value = GFFormsModel::get_field_value($field, $field_values);
                     }
                     $form_string .= self::get_field($field, $field_value, false, $form, $field_values);
                 }
             }
         }
         $form_string .= '
                         </ul>';
         if ($has_pages) {
             $previous_button = self::get_form_button($form['id'], "gform_previous_button_{$form['id']}", $form['lastPageButton'], __('Previous', 'gravityforms'), 'gform_previous_button', __('Previous Page', 'gravityforms'), self::get_current_page($form_id) - 1);
             $previous_button = gf_apply_filters('gform_previous_button', $form_id, $previous_button, $form);
             $form_string .= '</div>' . self::gform_footer($form, 'gform_page_footer ' . $form['labelPlacement'], $ajax, $field_values, $previous_button, $display_title, $display_description, $is_postback) . '
                     </div>';
             //closes gform_page
         }
         $form_string .= '</div>';
         //closes gform_body
         //suppress form footer for multi-page forms (footer will be included on the last page
         if (!$has_pages) {
             $form_string .= self::gform_footer($form, 'gform_footer ' . $form['labelPlacement'], $ajax, $field_values, '', $display_title, $display_description, $tabindex);
         }
         // echo "submition id 1 " . $form['id'] . '<br>';
         $form_string .= '
                     </form>
                     </div>';
         if ($ajax && $is_postback) {
             global $wp_scripts;
             $form_string = apply_filters('gform_ajax_iframe_content', '<!DOCTYPE html><html><head>' . "<meta charset='UTF-8' /></head><body class='GF_AJAX_POSTBACK'>" . $form_string . '</body></html>');
         }
         if ($ajax && !$is_postback) {
             $spinner_url = gf_apply_filters('gform_ajax_spinner_url', $form_id, GFCommon::get_base_url() . '/images/spinner.gif', $form);
             $scroll_position = array('default' => '', 'confirmation' => '');
             if ($use_anchor !== false) {
                 $scroll_position['default'] = is_numeric($use_anchor) ? 'jQuery(document).scrollTop(' . intval($use_anchor) . ');' : "jQuery(document).scrollTop(jQuery('#gform_wrapper_{$form_id}').offset().top);";
                 $scroll_position['confirmation'] = is_numeric($use_anchor) ? 'jQuery(document).scrollTop(' . intval($use_anchor) . ');' : "jQuery(document).scrollTop(jQuery('#gforms_confirmation_message_{$form_id}').offset().top);";
             }
             $iframe_style = defined('GF_DEBUG') && GF_DEBUG ? 'display:block;width:600px;height:300px;border:1px solid #eee;' : 'display:none;width:0px;height:0px;';
             $is_html5 = RGFormsModel::is_html5_enabled();
             $iframe_title = $is_html5 ? " title='Ajax Frame'" : '';
             $form_string .= "\n                <iframe style='{$iframe_style}' src='about:blank' name='gform_ajax_frame_{$form_id}' id='gform_ajax_frame_{$form_id}'" . $iframe_title . "></iframe>\n                <script type='text/javascript'>" . apply_filters('gform_cdata_open', '') . '' . 'jQuery(document).ready(function($){' . "gformInitSpinner( {$form_id}, '{$spinner_url}' );" . "jQuery('#gform_ajax_frame_{$form_id}').load( function(){" . "var contents = jQuery(this).contents().find('*').html();" . "var is_postback = contents.indexOf('GF_AJAX_POSTBACK') >= 0;" . 'if(!is_postback){return;}' . "var form_content = jQuery(this).contents().find('#gform_wrapper_{$form_id}');" . "var is_confirmation = jQuery(this).contents().find('#gform_confirmation_wrapper_{$form_id}').length > 0;" . "var is_redirect = contents.indexOf('gformRedirect(){') >= 0;" . 'var is_form = form_content.length > 0 && ! is_redirect && ! is_confirmation;' . 'if(is_form){' . "jQuery('#gform_wrapper_{$form_id}').html(form_content.html());" . "setTimeout( function() { /* delay the scroll by 50 milliseconds to fix a bug in chrome */ {$scroll_position['default']} }, 50 );" . "if(window['gformInitDatepicker']) {gformInitDatepicker();}" . "if(window['gformInitPriceFields']) {gformInitPriceFields();}" . "var current_page = jQuery('#gform_source_page_number_{$form_id}').val();" . "gformInitSpinner( {$form_id}, '{$spinner_url}' );" . "jQuery(document).trigger('gform_page_loaded', [{$form_id}, current_page]);" . "window['gf_submitting_{$form_id}'] = false;" . '}' . 'else if(!is_redirect){' . "var confirmation_content = jQuery(this).contents().find('#gforms_confirmation_message_{$form_id}').html();" . 'if(!confirmation_content){' . 'confirmation_content = contents;' . '}' . 'setTimeout(function(){' . "jQuery('#gform_wrapper_{$form_id}').replaceWith('<' + 'div id=\\'gforms_confirmation_message_{$form_id}\\' class=\\'gform_confirmation_message_{$form_id} gforms_confirmation_message\\'' + '>' + confirmation_content + '<' + '/div' + '>');" . "{$scroll_position['confirmation']}" . "jQuery(document).trigger('gform_confirmation_loaded', [{$form_id}]);" . "window['gf_submitting_{$form_id}'] = false;" . '}, 50);' . '}' . 'else{' . "jQuery('#gform_{$form_id}').append(contents);" . "if(window['gformRedirect']) {gformRedirect();}" . '}' . "jQuery(document).trigger('gform_post_render', [{$form_id}, current_page]);" . '} );' . '} );' . apply_filters('gform_cdata_close', '') . '</script>';
         }
         $is_first_load = !$is_postback;
         if (!$ajax || $is_first_load) {
             self::register_form_init_scripts($form, $field_values, $ajax);
             if (apply_filters('gform_init_scripts_footer', false)) {
                 add_action('wp_footer', create_function('', 'GFFormDisplay::footer_init_scripts(' . $form['id'] . ');'), 20);
                 add_action('gform_preview_footer', create_function('', 'GFFormDisplay::footer_init_scripts(' . $form['id'] . ');'));
             } else {
                 $form_string .= self::get_form_init_scripts($form);
                 $form_string .= "<script type='text/javascript'>" . apply_filters('gform_cdata_open', '') . " jQuery(document).ready(function(){jQuery(document).trigger('gform_post_render', [{$form_id}, {$current_page}]) } ); " . apply_filters('gform_cdata_close', '') . '</script>';
             }
         }
         return gf_apply_filters('gform_get_form_filter', $form_id, $form_string, $form);
     } else {
         $progress_confirmation = '';
         //check admin setting for whether the progress bar should start at zero
         $start_at_zero = rgars($form, 'pagination/display_progressbar_on_confirmation');
         $start_at_zero = apply_filters('gform_progressbar_start_at_zero', $start_at_zero, $form);
         //show progress bar on confirmation
         if ($start_at_zero && $has_pages && !$is_admin && ($form['confirmation']['type'] == 'message' && $form['pagination']['type'] == 'percentage')) {
             $progress_confirmation = self::get_progress_bar($form, $form_id, $confirmation_message);
             if ($ajax) {
                 $progress_confirmation = apply_filters('gform_ajax_iframe_content', "<!DOCTYPE html><html><head><meta charset='UTF-8' /></head><body class='GF_AJAX_POSTBACK'>" . $progress_confirmation . '</body></html>');
             }
         } else {
             //return regular confirmation message
             if ($ajax) {
                 $progress_confirmation = apply_filters('gform_ajax_iframe_content', "<!DOCTYPE html><html><head><meta charset='UTF-8' /></head><body class='GF_AJAX_POSTBACK'>" . $confirmation_message . '</body></html>');
             } else {
                 $progress_confirmation = $confirmation_message;
             }
         }
         return $progress_confirmation;
     }
 }
Beispiel #11
0
function woo_ce_extend_order_items_combined( $order ) {

	global $export;

	// Product Add-ons - http://www.woothemes.com/
	$product_addons = woo_ce_get_product_addons();
	if( $product_addons && $order->order_items ) {
		foreach( $product_addons as $product_addon ) {
			foreach( $order->order_items as $order_item ) {
				if( isset( $order_item->product_addons[$product_addon->post_name] ) )
					$order->{'order_items_product_addon_' . $product_addon->post_name} .= $order_item->product_addons[$product_addon->post_name] . $export->category_separator;
			}
			if( isset( $order->{'order_items_product_addon_' . $product_addon->post_name} ) )
				$order->{'order_items_product_addon_' . $product_addon->post_name} = substr( $order->{'order_items_product_addon_' . $product_addon->post_name}, 0, -1 );
		}
	}

	// Gravity Forms - http://woothemes.com/woocommerce
	$gf_fields = woo_ce_get_gravity_form_fields();
	if( $gf_fields && $order->order_items ) {
		$meta_type = 'order_item';
		$order->order_items_gf_form_id = '';
		$order->order_items_gf_form_label = '';
		foreach( $order->order_items as $order_item ) {
			$gravity_forms_history = get_metadata( $meta_type, $order_item->id, '_gravity_forms_history', true );
			// Check that Gravity Forms Order item meta isn't empty
			if( !empty( $gravity_forms_history ) ) {
				if( isset( $gravity_forms_history['_gravity_form_data'] ) ) {
					$order->order_items_gf_form_id .= $gravity_forms_history['_gravity_form_data']['id'] . $export->category_separator;
					$gravity_form = ( method_exists( 'RGFormsModel', 'get_form' ) ? RGFormsModel::get_form( $gravity_forms_history['_gravity_form_data']['id'] ) : array() );
					$order->order_items_gf_form_label .= ( !empty( $gravity_form ) ? $gravity_form->title : '' ) . $export->category_separator;
					unset( $gravity_form );
				}
			}
			foreach( $gf_fields as $gf_field ) {
				// Check that we only fill export fields for forms that are actually filled
				if( $gf_field['formId'] == $gravity_forms_history['_gravity_form_data']['id'] )
					$order->{sprintf( 'order_items_gf_%d_%s', $gf_field['formId'], $gf_field['id'] )} .= get_metadata( $meta_type, $order_item->id, $gf_field['label'], true ) . $export->category_separator;
			}
			unset( $gravity_forms_history );
		}
		if( isset( $order->order_items_gf_form_id ) )
			$order->order_items_gf_form_id = substr( $order->order_items_gf_form_id, 0, -1 );
		if( isset( $order->order_items_gf_form_label ) )
			$order->order_items_gf_form_label = substr( $order->order_items_gf_form_label, 0, -1 );
		if( isset( $order->{sprintf( 'order_items_gf_%d_%s', $gf_field['formId'], $gf_field['id'] )} ) )
			$order->{sprintf( 'order_items_gf_%d_%s', $gf_field['formId'], $gf_field['id'] )} = substr( $order->{sprintf( 'order_items_gf_%d_%s', $gf_field['formId'], $gf_field['id'] )}, 0, -1 );
	}

	// WooCommerce Checkout Add-Ons - http://www.skyverge.com/product/woocommerce-checkout-add-ons/
	if( function_exists( 'init_woocommerce_checkout_add_ons' ) && $order->order_items ) {
		$meta_type = 'order_item';
		foreach( $order->order_items as $order_item ) {
			$order->order_items_checkout_addon_id .= $order_item->checkout_addon_id . $export->category_separator;
			$order->order_items_checkout_addon_label .= $order_item->checkout_addon_label . $export->category_separator;
			$order->order_items_checkout_addon_value .= $order_item->checkout_addon_value . $export->category_separator;
		}
		if( isset( $order->order_items_checkout_addon_id ) )
			$order->order_items_checkout_addon_id = substr( $order->order_items_checkout_addon_id, 0, -1 );
		if( isset( $order->order_items_checkout_addon_label ) )
			$order->order_items_checkout_addon_label = substr( $order->order_items_checkout_addon_label, 0, -1 );
		if( isset( $order->order_items_checkout_addon_value ) )
			$order->order_items_checkout_addon_value = substr( $order->order_items_checkout_addon_value, 0, -1 );
	}

	// WooCommerce Brands Addon - http://woothemes.com/woocommerce/
	// WooCommerce Brands - http://proword.net/Woocommerce_Brands/
	if( ( class_exists( 'WC_Brands' ) || class_exists( 'woo_brands' ) || taxonomy_exists( apply_filters( 'woo_ce_brand_term_taxonomy', 'product_brand' ) ) ) && $order->order_items ) {
		$meta_type = 'order_item';
		foreach( $order->order_items as $order_item )
			$order->order_items_brand .= woo_ce_get_product_assoc_brands( $order_item->product_id ) . $export->category_separator;
		if( isset( $order->order_items_brand ) )
			$order->order_items_brand = substr( $order->order_items_brand, 0, -1 );
	}

	// Product Vendors - http://www.woothemes.com/products/product-vendors/
	if( class_exists( 'WooCommerce_Product_Vendors' ) && $order->order_items ) {
		$meta_type = 'order_item';
		foreach( $order->order_items as $order_item )
			$order->order_items_vendor = woo_ce_get_product_assoc_product_vendors( $order_item->product_id ) . $export->category_separator;
		if( isset( $order->order_items_vendor ) )
			$order->order_items_vendor = substr( $order->order_items_vendor, 0, -1 );
	}

	// Cost of Goods - http://www.skyverge.com/product/woocommerce-cost-of-goods-tracking/
	if( class_exists( 'WC_COG' ) && $order->order_items ) {
		$meta_type = 'order_item';
		foreach( $order->order_items as $order_item ) {
			$order->order_items_cost_of_goods .= woo_ce_format_price( get_metadata( $meta_type, $order_item->id, '_wc_cog_item_cost', true ), $order->order_currency ) . $export->category_separator;
			$order->order_items_total_cost_of_goods .= woo_ce_format_price( get_metadata( $meta_type, $order_item->id, '_wc_cog_item_total_cost', true ), $order->order_currency ) . $export->category_separator;
		}
		if( isset( $order->order_items_cost_of_goods ) )
			$order->order_items_cost_of_goods = substr( $order->order_items_cost_of_goods, 0, -1 );
		if( isset( $order->order_items_total_cost_of_goods ) )
			$order->order_items_total_cost_of_goods = substr( $order->order_items_total_cost_of_goods, 0, -1 );
	}

	// WooCommerce MSRP Pricing - http://woothemes.com/woocommerce/
	if( function_exists( 'woocommerce_msrp_activate' ) && $order->order_items ) {
		foreach( $order->order_items as $order_item ) {
			$order->order_items_msrp .= woo_ce_format_price( get_post_meta( $order_item->product_id, '_msrp_price', true ) ) . $export->category_separator;
		}
		if( isset( $order->order_items_msrp ) )
			$order->order_items_msrp = substr( $order->order_items_msrp, 0, -1 );
	}

	// Local Pickup Plus - http://www.woothemes.com/products/local-pickup-plus/
	if( class_exists( 'WC_Local_Pickup_Plus' ) && $order->order_items ) {
		$meta_type = 'order_item';
		$order->order_items_pickup_location = '';
		foreach( $order->order_items as $order_item ) {
			$pickup_location = get_metadata( $meta_type, $order_item->id, 'Pickup Location', true );
			if( !empty( $pickup_location ) )
				$order->order_items_pickup_location .= get_metadata( $meta_type, $order_item->id, 'Pickup Location', true ) . $export->category_separator;
			unset( $pickup_location );
		}
		if( isset( $order->order_items_pickup_location ) )
			$order->order_items_pickup_location = substr( $order->order_items_pickup_location, 0, -1 );
	}

	// WooCommerce Bookings - http://www.woothemes.com/products/woocommerce-bookings/
	if( class_exists( 'WC_Bookings' ) && $order->order_items ) {
		$meta_type = 'order_item';
		$order->order_items_booking_id = '';
		$order->order_items_booking_date = '';
		$order->order_items_booking_type = '';
		$order->order_items_booking_start_date = '';
		$order->order_items_booking_end_date = '';
		foreach( $order->order_items as $order_item ) {
			$booking_id = woo_ce_get_order_assoc_booking_id( $order->id );
			if( !empty( $booking_id ) ) {
				$order->order_items_booking_id .= $booking_id . $export->category_separator;
				$booking_start_date = get_post_meta( $booking_id, '_booking_start', true );
				if( !empty( $booking_start_date ) )
					$order->order_items_start_date .= woo_ce_format_date( date( 'Y-m-d', strtotime( $booking_start_date ) ) ) . $export->category_separator;
				unset( $booking_start_date );
				$booking_end_date = get_post_meta( $booking_id, '_booking_end', true );
				if( !empty( $booking_end_date ) )
					$order->order_items_booking_end_date .= woo_ce_format_date( date( 'Y-m-d', strtotime( $booking_end_date ) ) ) . $export->category_separator;
				unset( $booking_end_date );
			}
			unset( $booking_id );
			$booking_date = get_metadata( $meta_type, $order_item->id, 'Booking Date', true );
			if( !empty( $booking_date ) )
				$order->order_items_booking_date .= get_metadata( $meta_type, $order_item->id, 'Booking Date', true ) . $export->category_separator;
			unset( $booking_date );
			$booking_type = get_metadata( $meta_type, $order_item->id, 'Booking Type', true );
			if( !empty( $booking_type ) )
				$order->order_items_booking_type .= get_metadata( $meta_type, $order_item->id, 'Booking Type', true ) . $export->category_separator;
			unset( $booking_type );
		}
		if( isset( $order->order_items_booking_id ) )
			$order->order_items_booking_id = substr( $order->order_items_booking_id, 0, -1 );
		if( isset( $order->order_items_booking_date ) )
			$order->order_items_booking_date = substr( $order->order_items_booking_date, 0, -1 );
		if( isset( $order->order_items_booking_type ) )
			$order->order_items_booking_type = substr( $order->order_items_booking_type, 0, -1 );
		if( isset( $order->order_items_booking_start_date ) )
			$order->order_items_booking_start_date = substr( $order->order_items_booking_start_date, 0, -1 );
		if( isset( $order->order_items_booking_end_date ) )
			$order->order_items_booking_end_date = substr( $order->order_items_booking_end_date, 0, -1 );
	}

	// WooCommerce TM Extra Product Options - http://codecanyon.net/item/woocommerce-extra-product-options/7908619
	if( class_exists( 'TM_Extra_Product_Options' ) && $order->order_items ) {
		if( $tm_fields = woo_ce_get_extra_product_option_fields() ) {
			foreach( $tm_fields as $tm_field )
				$order->{'order_items_tm_' . sanitize_key( $tm_field['name'] )} = '';
			foreach( $order->order_items as $order_item ) {
				foreach( $tm_fields as $tm_field )
					$order->{sprintf( 'order_items_tm_%s', sanitize_key( $tm_field['name'] ) )} .= $order_item->{'tm_' . sanitize_key( $tm_field['name'] )} . $export->category_separator;
			}
			foreach( $tm_fields as $tm_field ) {
				if( isset( $order->{sprintf( 'order_items_tm_%s', sanitize_key( $tm_field['name'] ) )} ) )
					$order->{sprintf( 'order_items_tm_%s', sanitize_key( $tm_field['name'] ) )} = substr( $order->{sprintf( 'order_items_tm_%s', sanitize_key( $tm_field['name'] ) )}, 0, -1 );
			}
		}
	}

	// Barcodes for WooCommerce - http://www.wolkenkraft.com/produkte/barcodes-fuer-woocommerce/
	if( function_exists( 'wpps_requirements_met' ) ) {
		foreach( $order->order_items as $order_item ) {
			$order->order_items_barcode_type .= get_post_meta( $order_item->product_id, '_barcode_type', true ) . $export->category_separator;
			$order->order_items_barcode .= get_post_meta( $order_item->product_id, '_barcode', true ) . $export->category_separator;
		}
		if( isset( $order->order_items_barcode_type ) )
			$order->order_items_barcode_type = substr( $order->order_items_barcode_type, 0, -1 );
		if( isset( $order->order_items_barcode ) )
			$order->order_items_barcode = substr( $order->order_items_barcode, 0, -1 );
	}

	// Attributes
	$attributes = woo_ce_get_product_attributes();
	if( $attributes && $order->order_items ) {
		foreach( $attributes as $attribute )
			$order->{'order_items_attribute_' . sanitize_key( $attribute->attribute_name )} = '';
		foreach( $order->order_items as $order_item ) {
			foreach( $attributes as $attribute ) {
				if( isset( $order_item->{'attribute_' . $attribute->attribute_name} ) )
					$order->{'order_items_attribute_' . sanitize_key( $attribute->attribute_name )} .= $order_item->{'attribute_' . $attribute->attribute_name} . $export->category_separator;
			}
		}
		foreach( $attributes as $attribute ) {
			if( isset( $order->{'order_items_attribute_' . sanitize_key( $attribute->attribute_name )} ) )
				$order->{'order_items_attribute_' . sanitize_key( $attribute->attribute_name )} = substr( $order->{'order_items_attribute_' . sanitize_key( $attribute->attribute_name )}, 0, -1 );
		}
		unset( $attributes, $attribute );
	}

	// Custom Order Items fields
	$custom_order_items = woo_ce_get_option( 'custom_order_items', '' );
	if( !empty( $custom_order_items ) && $order->order_items ) {
		foreach( $custom_order_items as $custom_order_item )
			$order->{'order_items_' . $custom_order_item} = '';
		foreach( $order->order_items as $order_item ) {
			foreach( $custom_order_items as $custom_order_item ) {
				if( !empty( $custom_order_item ) )
					$order->{'order_items_' . $custom_order_item} .= $order_item->{$custom_order_item} . $export->category_separator;
			}
		}
		foreach( $custom_order_items as $custom_order_item ) {
			if( isset( $order->{'order_items_' . $custom_order_item} ) )
				$order->{'order_items_' . $custom_order_item} = substr( $order->{'order_items_' . $custom_order_item}, 0, -1 );
		}
	}

	// Custom Product fields
	$custom_products = woo_ce_get_option( 'custom_products', '' );
	if( !empty( $custom_products ) ) {
		foreach( $custom_products as $custom_product )
			$order->{'order_items_' . $custom_product} = '';
		foreach( $order->order_items as $order_item ) {
			foreach( $custom_products as $custom_product ) {
				if( !empty( $custom_product ) )
					$order->{'order_items_' . $custom_product} .= $order_item->{$custom_product} . $export->category_separator;
			}
		}
		foreach( $custom_products as $custom_product ) {
			if( isset( $order->{'order_items_' . $custom_product} ) )
				$order->{'order_items_' . $custom_product} = substr( $order->{'order_items_' . $custom_product}, 0, -1 );
		}
	}

	return $order;

}
Beispiel #12
0
 public static function get_form($form_id, $display_title = true, $display_description = true, $force_display = false, $field_values = null)
 {
     //reading form metadata
     $form = RGFormsModel::get_form_meta($form_id);
     //Fired right before the form rendering process. Allow users to manipulate the form object before it gets displayed in the front end
     $form = apply_filters("gform_pre_render_{$form_id}", apply_filters("gform_pre_render", $form));
     if ($form == null) {
         return "<p>" . __("Oops! We could not locate your form.", "gravityforms") . "</p>";
     }
     //Don't display inactive forms
     if (!$force_display) {
         $form_info = RGFormsModel::get_form($form_id);
         if (!$form_info->is_active) {
             return "";
         }
         //If form has a schedule, make sure it is within the configured start and end dates
         if ($form["scheduleForm"]) {
             $local_time_start = sprintf("%s %02d:%02d %s", $form["scheduleStart"], $form["scheduleStartHour"], $form["scheduleStartMinute"], $form["scheduleStartAmpm"]);
             $local_time_end = sprintf("%s %02d:%02d %s", $form["scheduleEnd"], $form["scheduleEndHour"], $form["scheduleEndMinute"], $form["scheduleEndAmpm"]);
             $timestamp_start = strtotime($local_time_start . ' +0000');
             $timestamp_end = strtotime($local_time_end . ' +0000');
             $now = current_time("timestamp");
             if (!empty($form["scheduleStart"]) && $now < $timestamp_start || !empty($form["scheduleEnd"]) && $now > $timestamp_end) {
                 return empty($form["scheduleMessage"]) ? "<p>" . __("Sorry. This form is no longer available.", "gravityforms") . "</p>" : "<p>" . $form["scheduleMessage"] . "</p>";
             }
         }
         //If form has a limit of entries, check current entry count
         if ($form["limitEntries"]) {
             $entry_count = RGFormsModel::get_lead_count($form_id, "");
             if ($entry_count >= $form["limitEntriesCount"]) {
                 return empty($form["limitEntriesMessage"]) ? "<p>" . __("Sorry. This form is no longer accepting new submissions.", "gravityforms") . "</p>" : "<p>" . $form["limitEntriesMessage"] . "</p>";
             }
         }
     }
     $form_string = "";
     //When called via a template, this will enqueue the proper scripts
     //When called via a shortcode, this will be ignored (too late to enqueue), but the scripts will be enqueued via the enqueue_scripts event
     self::enqueue_form_scripts($form);
     //handling postback if form was submitted
     $is_postback = $_POST["is_submit_" . $form_id];
     $is_valid = true;
     if ($is_postback) {
         $is_valid = self::validate($form, $field_values);
         if ($is_valid) {
             //pre submission action
             do_action("gform_pre_submission", $form);
             //pre submission filter
             $form = apply_filters("gform_pre_submission_filter", $form);
             //handle submission
             $lead = array();
             $confirmation_message = self::handle_submission($form, $lead);
             //post submission hook
             do_action("gform_post_submission", $lead, $form);
         }
     } else {
         //recording form view. Ignores views from administrators
         if (!current_user_can("administrator")) {
             RGFormsModel::insert_form_view($form_id, $_SERVER['REMOTE_ADDR']);
         }
     }
     if (empty($confirmation_message)) {
         //Hidding entire form if conditional logic is on to prevent "hidden" fields from blinking. Form will be set to visible in the conditional_logic.php after the rules have been applied.
         $style = self::has_conditional_logic($form) ? "style='display:none'" : "";
         $form_string .= "\n                <div class='gform_wrapper' id='gform_wrapper_{$form_id}' " . $style . ">\n                <form method='post' enctype='multipart/form-data' id='gform_{$form_id}' class='" . $form["cssClass"] . "' action=''>";
         if ($display_title || $display_description) {
             $form_string .= "\n                        <div class='gform_heading'>";
             if ($display_title) {
                 $form_string .= "\n                            <h3 class='gform_title'>" . $form['title'] . "</h3>";
             }
             if ($display_description) {
                 $form_string .= "\n                            <span class='gform_description'>" . $form['description'] . "</span>";
             }
             $form_string .= "\n                        </div>";
         }
         if ($is_postback && !$is_valid) {
             $validation_message = "<div class='validation_error'>" . __("There was a problem with your submission.", "gravityforms") . "<br /> " . __("Errors have been highlighted below ", "gravityforms") . "</div>";
             $form_string .= apply_filters("gform_validation_message", $validation_message, $form);
         }
         $form_string .= "\n                        <div class='gform_body'>\n                            <input type='hidden' class='gform_hidden' name='is_submit_{$form_id}' value='1'/>\n                            <ul id='gform_fields_{$form_id}' class='gform_fields " . $form['labelPlacement'] . "'>";
         if (is_array($form['fields'])) {
             foreach ($form['fields'] as $field) {
                 $field["conditionalLogicFields"] = self::get_conditional_logic_fields($form, $field["id"]);
                 $form_string .= self::get_field($field, RGFormsModel::get_field_value($field, $field_values), false, $form, $field_values);
             }
         }
         $form_string .= "\n                            </ul>\n                        </div>\n                        <div class='gform_footer " . $form['labelPlacement'] . "'>";
         $tabindex = GFCommon::$tab_index++;
         if ($form["button"]["type"] == "text" || empty($form["button"]["imageUrl"])) {
             $button_text = empty($form["button"]["text"]) ? __("Submit", "gravityforms") : $form["button"]["text"];
             $button_input = "<input type='submit' class='button' value='" . esc_attr($button_text) . "' tabindex='{$tabindex}'/>";
         } else {
             $imageUrl = $form["button"]["imageUrl"];
             $button_input = "<input type='image' src='{$imageUrl}' tabindex='{$tabindex}'/>";
         }
         $button_input = apply_filters("gform_submit_button", $button_input, $form);
         $button_input = apply_filters("gform_submit_button_{$form_id}", $button_input, $form);
         $form_string .= $button_input;
         if (current_user_can("gform_full_access")) {
             $form_string .= "&nbsp;&nbsp;<a href='" . get_bloginfo("wpurl") . "/wp-admin/admin.php?page=gf_edit_forms&amp;id=" . $form_id . "'>" . __("Edit this form", "gravityforms") . "</a>";
         }
         $form_string .= "\n                        </div>\n                </form>\n                </div>";
         if (self::has_conditional_logic($form)) {
             $form_string .= self::get_conditional_logic($form);
         }
         return $form_string;
     } else {
         return $confirmation_message;
     }
 }
function TriggerOrderEmail($lead_id)
{
    $where = 'lead_id =' . $lead_id;
    $params = array('where' => $where);
    $list = TemplateData::getDocumentsList($params);
    if (count($list)) {
        $data = RGFormsModel::get_form($list[0]["form_id"]);
        $to = $list[0]['email'];
        //$subject =  "Glenister & Co | ".$data->title . " Document";
        $subject = "ORDER NO: " . $list[0]['file_id'] . " ";
        $message = "";
        $message .= "<p>Thank you for your order.    This will now be processed and you will receive an email with a PDF of your order together with the link to your documents.<br/></p>";
        $message .= "<table style='font-size: 10pt; color: navy;'>\n                        <tr><td>The SMSF Academy Pty Ltd</td></tr>\n                        <tr><td>Suite 2, Level 5, 350 Collins Street</td></tr>\n                        <tr><td>MELBOURNE VIC 3000</td></tr>\n                        <tr><td>thesmsfacademy.com.au</td></tr>\n                    </table>";
        $message .= "<p style='font-size: 8pt; color: rgb(0, 0, 102);'>Disclaimer:\n                        This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and delete this e-mail from your system. Any unauthorised copying, disclosure, dissemination or distribution of the material in this e-mail is strictly forbidden.  The sender and their employer, do not guarantee the integrity of any e-mails or attached files. E-mail transmission cannot be guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. The sender therefore does not accept liability for any such problems in the contents of this message which arise as a result of e-mail transmission.\n         </p>";
        $message .= "<p style='font-size: 9pt; font-family: Webdings; color: rgb(0, 176, 80);'> P </p> <p style=\"font-size: 9pt; font-family: 'Trebuchet MS', sans-serif; color: rgb(0, 176, 80);\">Before you print think about the environment</p>";
        return true;
        //SendEmailTo($to,$subject,$message);
    }
    return true;
}
    ?>
</th> -->
        <th scope="col" class="manage-column"><?php 
    _e("Action", "templatemerge");
    ?>
</th>
      </tr>
    </thead>
    <tbody class="">
      <?php 
    $docs = TemplateData::get_completed_orders($form_id, $name, $email, $file_id, $paging, $current_user_id);
    // print_r($forms);
    if (is_array($docs) && sizeof($docs) > 0) {
        $i = 0;
        foreach ($docs as $doc) {
            $data = RGFormsModel::get_form($doc["fid"]);
            if ($doc['fid'] == TemplateData::companyform_id()) {
                TemplateData::get_certificates($doc['leadid']);
            }
            ?>
      <tr class='' valign="top">
        <td class="" ><?php 
            echo ++$i;
            ?>
</td>
        
        <td class="" ><?php 
            echo date('d/m/Y', strtotime($doc["date_created"]));
            ?>
</td>
       <td><?php 
 /**
  * Helper for getting the Form column value.
  *
  * @param integer $formid The ID the coupon is assigned to or zero for all forms.
  *
  * @return string
  */
 public function get_form_name($formid)
 {
     if ($formid == '0') {
         return esc_html__('Any Form', 'gravityformscoupons');
     }
     $form = RGFormsModel::get_form($formid);
     if (!$form) {
         return esc_html__('Invalid Form', 'gravityformscoupons');
     }
     return $form->title;
 }
Beispiel #16
0
 function get_value_for_api($post_id, $field)
 {
     // get value
     $value = parent::get_value($post_id, $field);
     // format value
     if (!$value) {
         return false;
     }
     if ($value == 'null') {
         return false;
     }
     // load form data
     if (is_array($value)) {
         foreach ($value as $k => $v) {
             $form = RGFormsModel::get_form($v);
             $value[$k] = $form;
         }
     } else {
         $value = RGFormsModel::get_form($value);
     }
     // return value
     return $value;
 }
 public function maybe_save_confirmation()
 {
     /* On paged forms all processing is suppressed, so we still need to do something */
     $form_id = isset($_POST['gform_submit']) ? $_POST['gform_submit'] : 0;
     if (!$form_id) {
         return;
     }
     if (!isset($_POST['gform_save_state_' . $form_id])) {
         return;
     }
     $form_info = RGFormsModel::get_form($form_id);
     $is_valid_form = $form_info && $form_info->is_active;
     if (!$is_valid_form) {
         return;
     }
     $form = RGFormsModel::get_form_meta($form_id);
     if (!isset($form['requireLogin']) || !isset($form['enableFormState'])) {
         return;
     }
     if (!$form['requireLogin'] || !$form['enableFormState']) {
         return;
     }
     if (!GFCommon::has_pages($form)) {
         return;
     }
     /* Spoof the page number and make-believe */
     $_POST["gform_target_page_number_{$form_id}"] = 65535;
     require_once GFCommon::get_base_path() . '/form_display.php';
     GFFormDisplay::process_form($form_id);
 }
 function get_gf_form($id, $display_title = true, $display_description = true, $force_display = false, $field_values = null)
 {
     if (class_exists('GFFormDisplay')) {
         return GFFormDisplay::get_form($id, $display_title = true, $display_description = true, $force_display = false, $field_values = null);
     } else {
         return RGFormsModel::get_form($id, $display_title, $display_description);
     }
 }
 public function maybe_save_confirmation()
 {
     /* On paged forms all processing is suppressed, so we still need to do something */
     $form_id = isset($_POST['gform_submit']) ? $_POST['gform_submit'] : 0;
     if (!$form_id) {
         return;
     }
     if (!isset($_POST['gform_save_state_' . $form_id])) {
         return;
     }
     $form_info = RGFormsModel::get_form($form_id);
     $is_valid_form = $form_info && $form_info->is_active;
     if (!$is_valid_form) {
         return;
     }
     $form = RGFormsModel::get_form_meta($form_id);
     if (!isset($form['requireLogin']) || !isset($form['enableFormState'])) {
         return;
     }
     //if ( !$form['requireLogin'] || !$form['enableFormState'] ) return;
     if (!is_user_logged_in() || !$form['enableFormState']) {
         return;
     }
     if (!GFCommon::has_pages($form)) {
         return;
     }
     /* Spoof the page number and make-believe */
     $_POST["gform_target_page_number_{$form_id}"] = 65535;
     //echo "<script type='text/javascript'>alert('Test".$form_id."');</script>";
     require_once 'D:\\inetpub\\app\\wwwroot\\wp-content\\plugins\\gravityforms\\form_display.php';
     global $wpdb;
     $id = rgget("q");
     $sql = "DELETE FROM " . $wpdb->prefix . "rg_lead WHERE id='" . $id . "'";
     $wpdb->query($sql);
     $sql = "DELETE FROM " . $wpdb->prefix . "rg_lead_meta WHERE lead_id='" . $id . "'";
     $wpdb->query($sql);
     //GFFormDisplay::process_form( $form_id );
 }
Beispiel #20
0
 /**
  * Update lead status of the specified payment
  *
  * @param string $payment
  */
 public function update_status(Pronamic_Pay_Payment $payment, $can_redirect = false)
 {
     $lead_id = $payment->get_source_id();
     $lead = RGFormsModel::get_lead($lead_id);
     if ($lead) {
         $form_id = $lead['form_id'];
         $form = RGFormsModel::get_form($form_id);
         $feed = get_pronamic_gf_pay_feed_by_entry_id($lead_id);
         $data = new Pronamic_WP_Pay_Extensions_GravityForms_PaymentData($form, $lead, $feed);
         if ($feed) {
             $url = null;
             switch ($payment->status) {
                 case Pronamic_WP_Pay_Statuses::CANCELLED:
                     $lead[Pronamic_WP_Pay_Extensions_GravityForms_LeadProperties::PAYMENT_STATUS] = Pronamic_WP_Pay_Extensions_GravityForms_PaymentStatuses::CANCELLED;
                     $url = $data->get_cancel_url();
                     break;
                 case Pronamic_WP_Pay_Statuses::EXPIRED:
                     $lead[Pronamic_WP_Pay_Extensions_GravityForms_LeadProperties::PAYMENT_STATUS] = Pronamic_WP_Pay_Extensions_GravityForms_PaymentStatuses::EXPIRED;
                     $url = $feed->get_url(Pronamic_WP_Pay_Extensions_GravityForms_Links::EXPIRED);
                     break;
                 case Pronamic_WP_Pay_Statuses::FAILURE:
                     $lead[Pronamic_WP_Pay_Extensions_GravityForms_LeadProperties::PAYMENT_STATUS] = Pronamic_WP_Pay_Extensions_GravityForms_PaymentStatuses::FAILED;
                     $url = $data->get_error_url();
                     break;
                 case Pronamic_WP_Pay_Statuses::SUCCESS:
                     if (!Pronamic_WP_Pay_Extensions_GravityForms_Entry::is_payment_approved($lead)) {
                         // Only fullfill order if the payment isn't approved aloready
                         $lead[Pronamic_WP_Pay_Extensions_GravityForms_LeadProperties::PAYMENT_STATUS] = Pronamic_WP_Pay_Extensions_GravityForms_PaymentStatuses::APPROVED;
                         // @see https://github.com/gravityforms/gravityformspaypal/blob/2.3.1/class-gf-paypal.php#L1741-L1742
                         if ($this->addon) {
                             $action = array('id' => $payment->get_transaction_id(), 'type' => 'complete_payment', 'transaction_id' => $payment->get_transaction_id(), 'amount' => $payment->get_amount(), 'entry_id' => $lead['id']);
                             $this->addon->complete_payment($lead, $action);
                         }
                         $this->fulfill_order($lead);
                     }
                     $url = $data->get_success_url();
                     break;
                 case Pronamic_WP_Pay_Statuses::OPEN:
                 default:
                     $url = $data->get_normal_return_url();
                     break;
             }
             Pronamic_WP_Pay_Extensions_GravityForms_GravityForms::update_entry($lead);
             if ($url && $can_redirect) {
                 wp_redirect($url);
                 exit;
             }
         }
     }
 }
 function do_propertyenquiryform_shortcode($atts, $content = null, $code = "")
 {
     global $wp_query;
     $defaults = array("property" => "define", "holder" => '', "holderclass" => '', "item" => '', "itemclass" => '', "postfix" => '', "prefix" => '', "wrapwith" => '', "wrapwithclass" => '', "ajax" => 'true', "title" => 'false');
     extract(shortcode_atts($defaults, $atts));
     if ($property == 'define' && defined('STAYPRESS_ON_PROPERTY_PAGE')) {
         $property = (int) STAYPRESS_ON_PROPERTY_PAGE;
     } elseif ($property == 'define' && $this->inshortcodelist == true && !empty($this->shortcodeproperty)) {
         $property = (int) $this->shortcodeproperty;
     } elseif ($property == 'post') {
         $property = get_the_id();
     }
     $formoption = SPPCommon::get_option('property_enquiry_options', array());
     $html = '';
     if (!empty($formoption['enquiry_form_gf_id'])) {
         // Add in hash url link
         $html .= "<a name='" . __('propertyenquiry', 'property') . "'></a>";
         if (!empty($holder)) {
             $html .= "<{$holder} class='{$holderclass}'>";
         }
         if (!empty($item)) {
             $html .= "<{$item} class='{$itemclass}'>";
         }
         $html .= $prefix;
         if (!empty($wrapwith)) {
             $html .= "<{$wrapwith} class='{$wrapwithclass}'>";
         }
         if (class_exists('RGFormsModel')) {
             $form = RGFormsModel::get_form($formoption['enquiry_form_gf_id']);
             if (!empty($form) && $form->is_active == 1) {
                 $html .= do_shortcode("[gravityform id=" . $formoption['enquiry_form_gf_id'] . " title={$title} ajax={$ajax}]");
             } else {
                 $html .= __('Your selected enquiry form could not be found.', 'property');
             }
         } else {
             // No Gravity Forms
             $html .= __('Gravity Forms not found.', 'property');
         }
         if (!empty($wrapwith)) {
             $html .= "</{$wrapwith}>";
         }
         $html .= $postfix;
         if (!empty($item)) {
             $html .= "</{$item}>";
         }
         if (!empty($holder)) {
             $html .= "</{$holder}>";
         }
     }
     return $html;
 }
    public static function display_page()
    {
        ?>
        
        <style type="text/css">
            .nav-tab-wrapper { margin: 0 0 10px !important; }
            .message { margin: 5px 0 15px; padding: 0.5em 0.6em; border: 1px solid #E6DB55; }
            .message.updated { background-color: #FFFFE0;  }
            .message.error { background-color: #FFEBE8; border-color: #CC0000; }
            .gfur-form-select { float: right; margin-top: -30px; }
        </style>
        
        <div class="wrap">

            <?php 
        $form = rgget('form_id') ? RGFormsModel::get_form(rgget('form_id')) : false;
        ?>

            <div style="background: url('<?php 
        echo GFUser::get_base_url();
        ?>
/images/user-registration-icon-32.png') no-repeat;" id="icon-edit" class="icon32 icon32-posts-post"><br></div>
            <h2>
                <?php 
        if (!$form) {
            _e("Pending Activations", "gravityformsuserregistration");
        } else {
            $form_link = '"<a href="' . admin_url('admin.php?page=gf_edit_forms&id=' . $form->id) . '">' . $form->title . '</a>"';
            printf(__('Pending Activations for %s'), $form_link);
        }
        ?>
            </h2>

            <div class="gfur-form-select">

                <?php 
        $pending_activation_forms = GFUser::get_pending_activation_forms();
        $pending_activation_url = admin_url('admin.php?page=gf_user_registration&view=pending_activations&form_id=');
        ?>
                <select onchange="document.location = '<?php 
        echo $pending_activation_url;
        ?>
' + this.value;">
                    <option value=""><?php 
        _e('Select a Form', 'gravityformsuserregistration');
        ?>
</option>
                    <option value="all"><?php 
        _e('View All Pending Activations', 'gravityformsuserregistration');
        ?>
                    <optgroup label="<?php 
        _e('Forms', 'gravityformsuserregistration');
        ?>
">
                        <?php 
        foreach ($pending_activation_forms as $form_obj) {
            ?>
                            <option value="<?php 
            echo $form_obj->id;
            ?>
"><?php 
            echo $form_obj->title;
            ?>
</option>
                        <?php 
        }
        ?>
                    </optgroup></option>
                </select>

            </div>

            <?php 
        if (rgpost('is_submit')) {
            self::handle_submission();
            if (self::$errors) {
                ?>
                    <div class="message error"><p><?php 
                echo self::$errors;
                ?>
</p></div>
                <?php 
            } else {
                ?>
                    <div class="message updated"><p><?php 
                echo self::$message;
                ?>
</p></div>
                <?php 
            }
        }
        ?>
            
            <form id="list_form" method="post" action="">
            
                <?php 
        $table = new GFUserPendingActivationsList();
        $table->prepare_items();
        $table->display();
        ?>
                
                <input type="hidden" name="is_submit" value="1" />
                <input type="hidden" id="single_action" name="single_action" value="" />
                <input type="hidden" id="item" name="item" value="" />
                
                <?php 
        wp_nonce_field('action', 'action_nonce');
        ?>
                
            </form>
            
        </div>
        
        <script type="text/javascript">
        
        function singleItemAction(action, activationKey) {
            jQuery('#item').val(activationKey);
            jQuery('#single_action').val(action);
            jQuery('#list_form')[0].submit();
        }
        
        </script>
        
        <?php 
    }
Beispiel #23
0
 public function is_formid_valid($form_id)
 {
     if (RGFormsModel::get_form($form_id) || '0' == $form_id) {
         return true;
     } else {
         return false;
     }
 }
                        <?php 
$forms = TemplateData::get_from_entries($paging);
// print_r($forms);
if (is_array($forms) && sizeof($forms) > 0) {
    $i = 0;
    foreach ($forms as $form) {
        ?>
                                <tr class='author-self status-inherit' valign="top">
                                    
                                    <td class="check-column" style="width:20%;text-align:center"><?php 
        echo ++$i;
        ?>
</td>
                                    <td class="column-date" style="font-weight:bold;color:#3D8CFF;font-size:14px">
                                    	<?php 
        $data = RGFormsModel::get_form($form["form_id"]);
        echo $data->title;
        ?>
                                     <div class="row-actions">
                                            <span class="edit">
                                            <a title="<?php 
        _e("Edit", "templatemerge");
        ?>
" href="admin.php?page=parsefield&view=field_map_list&formid=<?php 
        echo $form["form_id"];
        ?>
" ><?php 
        _e("Entries", "templatemerge");
        ?>
</a>
                                            </span>
Beispiel #25
0
 public static function get_form($form_id, $display_title = true, $display_description = true, $force_display = false, $field_values = null, $ajax = false, $tabindex = 1)
 {
     /**
      * Provides the ability to modify the options used to display the form
      *
      * @param array An array of Form Arguments when adding it to a page/post (Like the ID, Title, AJAX or not, etc)
      */
     $form_args = apply_filters('gform_form_args', compact('form_id', 'display_title', 'display_description', 'force_display', 'field_values', 'ajax', 'tabindex'));
     extract($form_args);
     //looking up form id by form name
     if (!is_numeric($form_id)) {
         $form_id = RGFormsModel::get_form_id($form_id);
     }
     //reading form metadata
     $form = GFAPI::get_form($form_id);
     $form = self::maybe_add_review_page($form);
     $action = remove_query_arg('gf_token');
     //disable ajax if form has a reCAPTCHA field (not supported).
     if ($ajax && self::has_recaptcha_field($form)) {
         $ajax = false;
     }
     if (isset($_POST['gform_send_resume_link'])) {
         $save_email_confirmation = self::handle_save_email_confirmation($form, $ajax);
         if (is_wp_error($save_email_confirmation)) {
             // Failed email validation
             $resume_token = rgpost('gform_resume_token');
             $resume_token = sanitize_key($resume_token);
             $incomplete_submission_info = GFFormsModel::get_incomplete_submission_values($resume_token);
             if ($incomplete_submission_info['form_id'] == $form_id) {
                 $submission_details_json = $incomplete_submission_info['submission'];
                 $submission_details = json_decode($submission_details_json, true);
                 $partial_entry = $submission_details['partial_entry'];
                 $form = self::update_confirmation($form, $partial_entry, 'form_saved');
                 $confirmation_message = rgar($form['confirmation'], 'message');
                 $nl2br = rgar($form['confirmation'], 'disableAutoformat') ? false : true;
                 $confirmation_message = GFCommon::replace_variables($confirmation_message, $form, $partial_entry, false, true, $nl2br);
                 return self::handle_save_confirmation($form, $resume_token, $confirmation_message, $ajax);
             }
         } else {
             return $save_email_confirmation;
         }
     }
     $is_postback = false;
     $is_valid = true;
     $confirmation_message = '';
     //If form was submitted, read variables set during form submission procedure
     $submission_info = isset(self::$submission[$form_id]) ? self::$submission[$form_id] : false;
     if (rgar($submission_info, 'saved_for_later') == true) {
         $resume_token = $submission_info['resume_token'];
         $confirmation_message = rgar($submission_info, 'confirmation_message');
         return self::handle_save_confirmation($form, $resume_token, $confirmation_message, $ajax);
     }
     $partial_entry = $submitted_values = false;
     if (isset($_GET['gf_token'])) {
         $incomplete_submission_info = GFFormsModel::get_incomplete_submission_values($_GET['gf_token']);
         if ($incomplete_submission_info['form_id'] == $form_id) {
             $submission_details_json = $incomplete_submission_info['submission'];
             $submission_details = json_decode($submission_details_json, true);
             $partial_entry = $submission_details['partial_entry'];
             $submitted_values = $submission_details['submitted_values'];
             $field_values = $submission_details['field_values'];
             GFFormsModel::$unique_ids[$form_id] = $submission_details['gform_unique_id'];
             GFFormsModel::$uploaded_files[$form_id] = $submission_details['files'];
             self::set_submission_if_null($form_id, 'resuming_incomplete_submission', true);
             self::set_submission_if_null($form_id, 'form_id', $form_id);
             $max_page_number = self::get_max_page_number($form);
             $page_number = $submission_details['page_number'] > $max_page_number ? $max_page_number : $submission_details['page_number'];
             self::set_submission_if_null($form_id, 'page_number', $page_number);
         }
     }
     if (!is_array($partial_entry)) {
         /**
          * A filter that allows disabling of the form view counter
          *
          * @param int $form_id The Form ID to filter when disabling the form view counter
          * @param bool Default set to false (view counter enabled), can be set to true to disable the counter
          */
         $view_counter_disabled = gf_apply_filters(array('gform_disable_view_counter', $form_id), false);
         if ($submission_info) {
             $is_postback = true;
             $is_valid = rgar($submission_info, 'is_valid') || rgar($submission_info, 'is_confirmation');
             $form = $submission_info['form'];
             $lead = $submission_info['lead'];
             $confirmation_message = rgget('confirmation_message', $submission_info);
             if ($is_valid && !RGForms::get('is_confirmation', $submission_info)) {
                 if ($submission_info['page_number'] == 0) {
                     /**
                      * Fired after form submission
                      *
                      * @param array $lead The Entry object
                      * @param array $form The Form object
                      */
                     gf_do_action(array('gform_post_submission', $form['id']), $lead, $form);
                 } else {
                     /**
                      * Fired after the page changes on a multi-page form
                      *
                      * @param array $form                                  The Form object
                      * @param int   $submission_info['source_page_number'] The page that was submitted
                      * @param int   $submission_info['page_number']        The page that the user is being sent to
                      */
                     gf_do_action(array('gform_post_paging', $form['id']), $form, $submission_info['source_page_number'], $submission_info['page_number']);
                 }
             }
         } elseif (!current_user_can('administrator') && !$view_counter_disabled) {
             RGFormsModel::insert_form_view($form_id, $_SERVER['REMOTE_ADDR']);
         }
     }
     if (rgar($form, 'enableHoneypot')) {
         $form['fields'][] = self::get_honeypot_field($form);
     }
     //Fired right before the form rendering process. Allow users to manipulate the form object before it gets displayed in the front end
     $form = gf_apply_filters(array('gform_pre_render', $form_id), $form, $ajax, $field_values);
     if ($form == null) {
         return '<p>' . esc_html__('Oops! We could not locate your form.', 'gravityforms') . '</p>';
     }
     $has_pages = self::has_pages($form);
     //calling tab index filter
     GFCommon::$tab_index = gf_apply_filters(array('gform_tabindex', $form_id), $tabindex, $form);
     //Don't display inactive forms
     if (!$force_display && !$is_postback) {
         $form_info = RGFormsModel::get_form($form_id);
         if (empty($form_info) || !$form_info->is_active) {
             return '';
         }
         // If form requires login, check if user is logged in
         if (rgar($form, 'requireLogin')) {
             if (!is_user_logged_in()) {
                 return empty($form['requireLoginMessage']) ? '<p>' . esc_html__('Sorry. You must be logged in to view this form.', 'gravityforms') . '</p>' : '<p>' . GFCommon::gform_do_shortcode($form['requireLoginMessage']) . '</p>';
             }
         }
     }
     // show the form regardless of the following validations when force display is set to true
     if (!$force_display || $is_postback) {
         $form_schedule_validation = self::validate_form_schedule($form);
         // if form schedule validation fails AND this is not a postback, display the validation error
         // if form schedule validation fails AND this is a postback, make sure is not a valid submission (enables display of confirmation message)
         if ($form_schedule_validation && !$is_postback || $form_schedule_validation && $is_postback && !$is_valid) {
             return $form_schedule_validation;
         }
         $entry_limit_validation = self::validate_entry_limit($form);
         // refer to form schedule condition notes above
         if ($entry_limit_validation && !$is_postback || $entry_limit_validation && $is_postback && !$is_valid) {
             return $entry_limit_validation;
         }
     }
     $form_string = '';
     //When called via a template, this will enqueue the proper scripts
     //When called via a shortcode, this will be ignored (too late to enqueue), but the scripts will be enqueued via the enqueue_scripts event
     self::enqueue_form_scripts($form, $ajax);
     $is_form_editor = GFCommon::is_form_editor();
     $is_entry_detail = GFCommon::is_entry_detail();
     $is_admin = $is_form_editor || $is_entry_detail;
     if (empty($confirmation_message)) {
         $wrapper_css_class = GFCommon::get_browser_class() . ' gform_wrapper';
         if (!$is_valid) {
             $wrapper_css_class .= ' gform_validation_error';
         }
         $form_css_class = esc_attr(rgar($form, 'cssClass'));
         //Hiding entire form if conditional logic is on to prevent 'hidden' fields from blinking. Form will be set to visible in the conditional_logic.php after the rules have been applied.
         $style = self::has_conditional_logic($form) ? "style='display:none'" : '';
         $custom_wrapper_css_class = !empty($form_css_class) ? " {$form_css_class}_wrapper" : '';
         $form_string .= "\n                <div class='{$wrapper_css_class}{$custom_wrapper_css_class}' id='gform_wrapper_{$form_id}' " . $style . '>';
         $default_anchor = $has_pages || $ajax ? true : false;
         $use_anchor = gf_apply_filters(array('gform_confirmation_anchor', $form_id), $default_anchor);
         if ($use_anchor !== false) {
             $form_string .= "<a id='gf_{$form_id}' class='gform_anchor' ></a>";
             $action .= "#gf_{$form_id}";
         }
         $target = $ajax ? "target='gform_ajax_frame_{$form_id}'" : '';
         $form_css_class = !empty($form['cssClass']) ? "class='{$form_css_class}'" : '';
         $action = esc_url($action);
         $form_string .= gf_apply_filters(array('gform_form_tag', $form_id), "<form method='post' enctype='multipart/form-data' {$target} id='gform_{$form_id}' {$form_css_class} action='{$action}'>", $form);
         if ($display_title || $display_description) {
             $form_string .= "\n                        <div class='gform_heading'>";
             if ($display_title) {
                 $form_string .= "\n                            <h3 class='gform_title'>" . $form['title'] . '</h3>';
             }
             if ($display_description) {
                 $form_string .= "\n                            <span class='gform_description'>" . rgar($form, 'description') . '</span>';
             }
             $form_string .= '
                     </div>';
         }
         $current_page = self::get_current_page($form_id);
         if ($has_pages && !$is_admin) {
             if ($form['pagination']['type'] == 'percentage') {
                 $form_string .= self::get_progress_bar($form, $form_id, $confirmation_message);
             } else {
                 if ($form['pagination']['type'] == 'steps') {
                     $form_string .= "\n                    <div id='gf_page_steps_{$form_id}' class='gf_page_steps'>";
                     $pages = isset($form['pagination']['pages']) ? $form['pagination']['pages'] : array();
                     for ($i = 0, $count = sizeof($pages); $i < $count; $i++) {
                         $step_number = $i + 1;
                         $active_class = $step_number == $current_page ? ' gf_step_active' : '';
                         $first_class = $i == 0 ? ' gf_step_first' : '';
                         $last_class = $i + 1 == $count ? ' gf_step_last' : '';
                         $complete_class = $step_number < $current_page ? ' gf_step_completed' : '';
                         $previous_class = $step_number + 1 == $current_page ? ' gf_step_previous' : '';
                         $next_class = $step_number - 1 == $current_page ? ' gf_step_next' : '';
                         $pending_class = $step_number > $current_page ? ' gf_step_pending' : '';
                         $classes = 'gf_step' . $active_class . $first_class . $last_class . $complete_class . $previous_class . $next_class . $pending_class;
                         $classes = GFCommon::trim_all($classes);
                         $form_string .= "\n                        <div id='gf_step_{$form_id}_{$step_number}' class='{$classes}'><span class='gf_step_number'>{$step_number}</span>&nbsp;<span class='gf_step_label'>{$pages[$i]}</span></div>";
                     }
                     $form_string .= "\n                        <div class='gf_step_clear'></div>\n                    </div>";
                 }
             }
         }
         if ($is_postback && !$is_valid) {
             $validation_message = "<div class='validation_error'>" . esc_html__('There was a problem with your submission.', 'gravityforms') . ' ' . esc_html__('Errors have been highlighted below.', 'gravityforms') . '</div>';
             $form_string .= gf_apply_filters(array('gform_validation_message', $form_id), $validation_message, $form);
         }
         $form_string .= "\n                        <div class='gform_body'>";
         //add first page if this form has any page fields
         if ($has_pages) {
             $style = self::is_page_active($form_id, 1) ? '' : "style='display:none;'";
             $class = !empty($form['firstPageCssClass']) ? " {$form['firstPageCssClass']}" : '';
             $class = esc_attr($class);
             $form_string .= "<div id='gform_page_{$form_id}_1' class='gform_page{$class}' {$style}>\n                                    <div class='gform_page_fields'>";
         }
         $description_class = rgar($form, 'descriptionPlacement') == 'above' ? 'description_above' : 'description_below';
         $sublabel_class = rgar($form, 'subLabelPlacement') == 'above' ? 'form_sublabel_above' : 'form_sublabel_below';
         $form_string .= "<ul id='gform_fields_{$form_id}' class='" . GFCommon::get_ul_classes($form) . "'>";
         if (is_array($form['fields'])) {
             foreach ($form['fields'] as $field) {
                 /* @var GF_Field $field */
                 $field->conditionalLogicFields = self::get_conditional_logic_fields($form, $field->id);
                 if (is_array($submitted_values)) {
                     $field_value = rgar($submitted_values, $field->id);
                 } else {
                     $field_value = GFFormsModel::get_field_value($field, $field_values);
                 }
                 $form_string .= self::get_field($field, $field_value, false, $form, $field_values);
             }
         }
         $form_string .= '
                         </ul>';
         if ($has_pages) {
             $previous_button_alt = rgempty('imageAlt', $form['lastPageButton']) ? __('Previous Page', 'gravityforms') : $form['lastPageButton']['imageAlt'];
             $previous_button = self::get_form_button($form['id'], "gform_previous_button_{$form['id']}", $form['lastPageButton'], __('Previous', 'gravityforms'), 'gform_previous_button', $previous_button_alt, self::get_current_page($form_id) - 1);
             /**
              * Filter through the form previous button when paged
              *
              * @param int $form_id The Form ID to filter through
              * @param string $previous_button The HTML rendered button (rendered with the form ID and the function get_form_button)
              * @param array $form The Form object to filter through
              */
             $previous_button = gf_apply_filters(array('gform_previous_button', $form_id), $previous_button, $form);
             $form_string .= '</div>' . self::gform_footer($form, 'gform_page_footer ' . $form['labelPlacement'], $ajax, $field_values, $previous_button, $display_title, $display_description, $is_postback) . '
                     </div>';
             //closes gform_page
         }
         $form_string .= '</div>';
         //closes gform_body
         //suppress form footer for multi-page forms (footer will be included on the last page
         if (!$has_pages) {
             $form_string .= self::gform_footer($form, 'gform_footer ' . $form['labelPlacement'], $ajax, $field_values, '', $display_title, $display_description, $tabindex);
         }
         $form_string .= '
                     </form>
                     </div>';
         if ($ajax && $is_postback) {
             global $wp_scripts;
             $form_string = apply_filters('gform_ajax_iframe_content', '<!DOCTYPE html><html><head>' . "<meta charset='UTF-8' /></head><body class='GF_AJAX_POSTBACK'>" . $form_string . '</body></html>');
         }
         if ($ajax && !$is_postback) {
             $spinner_url = gf_apply_filters(array('gform_ajax_spinner_url', $form_id), GFCommon::get_base_url() . '/images/spinner.gif', $form);
             $scroll_position = array('default' => '', 'confirmation' => '');
             if ($use_anchor !== false) {
                 $scroll_position['default'] = is_numeric($use_anchor) ? 'jQuery(document).scrollTop(' . intval($use_anchor) . ');' : "jQuery(document).scrollTop(jQuery('#gform_wrapper_{$form_id}').offset().top);";
                 $scroll_position['confirmation'] = is_numeric($use_anchor) ? 'jQuery(document).scrollTop(' . intval($use_anchor) . ');' : "jQuery(document).scrollTop(jQuery('#gforms_confirmation_message_{$form_id}').offset().top);";
             }
             $iframe_style = defined('GF_DEBUG') && GF_DEBUG ? 'display:block;width:600px;height:300px;border:1px solid #eee;' : 'display:none;width:0px;height:0px;';
             $is_html5 = RGFormsModel::is_html5_enabled();
             $iframe_title = $is_html5 ? " title='Ajax Frame'" : '';
             $form_string .= "\n                <iframe style='{$iframe_style}' src='about:blank' name='gform_ajax_frame_{$form_id}' id='gform_ajax_frame_{$form_id}'" . $iframe_title . "></iframe>\n                <script type='text/javascript'>" . apply_filters('gform_cdata_open', '') . '' . 'jQuery(document).ready(function($){' . "gformInitSpinner( {$form_id}, '{$spinner_url}' );" . "jQuery('#gform_ajax_frame_{$form_id}').load( function(){" . "var contents = jQuery(this).contents().find('*').html();" . "var is_postback = contents.indexOf('GF_AJAX_POSTBACK') >= 0;" . 'if(!is_postback){return;}' . "var form_content = jQuery(this).contents().find('#gform_wrapper_{$form_id}');" . "var is_confirmation = jQuery(this).contents().find('#gform_confirmation_wrapper_{$form_id}').length > 0;" . "var is_redirect = contents.indexOf('gformRedirect(){') >= 0;" . 'var is_form = form_content.length > 0 && ! is_redirect && ! is_confirmation;' . 'if(is_form){' . "jQuery('#gform_wrapper_{$form_id}').html(form_content.html());" . "setTimeout( function() { /* delay the scroll by 50 milliseconds to fix a bug in chrome */ {$scroll_position['default']} }, 50 );" . "if(window['gformInitDatepicker']) {gformInitDatepicker();}" . "if(window['gformInitPriceFields']) {gformInitPriceFields();}" . "var current_page = jQuery('#gform_source_page_number_{$form_id}').val();" . "gformInitSpinner( {$form_id}, '{$spinner_url}' );" . "jQuery(document).trigger('gform_page_loaded', [{$form_id}, current_page]);" . "window['gf_submitting_{$form_id}'] = false;" . '}' . 'else if(!is_redirect){' . "var confirmation_content = jQuery(this).contents().find('#gforms_confirmation_message_{$form_id}').html();" . 'if(!confirmation_content){' . 'confirmation_content = contents;' . '}' . 'setTimeout(function(){' . "jQuery('#gform_wrapper_{$form_id}').replaceWith('<' + 'div id=\\'gforms_confirmation_message_{$form_id}\\' class=\\'gform_confirmation_message_{$form_id} gforms_confirmation_message\\'' + '>' + confirmation_content + '<' + '/div' + '>');" . "{$scroll_position['confirmation']}" . "jQuery(document).trigger('gform_confirmation_loaded', [{$form_id}]);" . "window['gf_submitting_{$form_id}'] = false;" . '}, 50);' . '}' . 'else{' . "jQuery('#gform_{$form_id}').append(contents);" . "if(window['gformRedirect']) {gformRedirect();}" . '}' . "jQuery(document).trigger('gform_post_render', [{$form_id}, current_page]);" . '} );' . '} );' . apply_filters('gform_cdata_close', '') . '</script>';
         }
         $is_first_load = !$is_postback;
         if (!$ajax || $is_first_load) {
             self::register_form_init_scripts($form, $field_values, $ajax);
             if (apply_filters('gform_init_scripts_footer', false)) {
                 add_action('wp_footer', create_function('', 'GFFormDisplay::footer_init_scripts(' . $form['id'] . ');'), 20);
                 add_action('gform_preview_footer', create_function('', 'GFFormDisplay::footer_init_scripts(' . $form['id'] . ');'));
             } else {
                 $form_string .= self::get_form_init_scripts($form);
                 $form_string .= "<script type='text/javascript'>" . apply_filters('gform_cdata_open', '') . " jQuery(document).ready(function(){jQuery(document).trigger('gform_post_render', [{$form_id}, {$current_page}]) } ); " . apply_filters('gform_cdata_close', '') . '</script>';
             }
         }
         return gf_apply_filters(array('gform_get_form_filter', $form_id), $form_string, $form);
     } else {
         $progress_confirmation = '';
         //check admin setting for whether the progress bar should start at zero
         $start_at_zero = rgars($form, 'pagination/display_progressbar_on_confirmation');
         $start_at_zero = apply_filters('gform_progressbar_start_at_zero', $start_at_zero, $form);
         //show progress bar on confirmation
         if ($start_at_zero && $has_pages && !$is_admin && ($form['confirmation']['type'] == 'message' && $form['pagination']['type'] == 'percentage')) {
             $progress_confirmation = self::get_progress_bar($form, $form_id, $confirmation_message);
             if ($ajax) {
                 $progress_confirmation = apply_filters('gform_ajax_iframe_content', "<!DOCTYPE html><html><head><meta charset='UTF-8' /></head><body class='GF_AJAX_POSTBACK'>" . $progress_confirmation . '</body></html>');
             }
         } else {
             //return regular confirmation message
             if ($ajax) {
                 $progress_confirmation = apply_filters('gform_ajax_iframe_content', "<!DOCTYPE html><html><head><meta charset='UTF-8' /></head><body class='GF_AJAX_POSTBACK'>" . $confirmation_message . '</body></html>');
             } else {
                 $progress_confirmation = $confirmation_message;
             }
         }
         return $progress_confirmation;
     }
 }
        function meta_box($post)
        {
            ?>

			<script type="text/javascript">
				jQuery(document).ready(function ($) {
					$('#gravityform-id').change(function () {
						if ($(this).val() != '') {
							$('.gforms-panel').show();
						} else {
							$('.gforms-panel').hide();
						}
					})
				});
			</script>
			<div id="gravityforms_data" class="panel woocommerce_options_panel">
				<h4><?php 
            _e('General', 'wc_gf_addons');
            ?>
</h4>
				<?php 
            $gravity_form_data = get_post_meta($post->ID, '_gravity_form_data', true);
            $gravityform = NULL;
            if (is_array($gravity_form_data) && isset($gravity_form_data['id']) && is_numeric($gravity_form_data['id'])) {
                $form_meta = RGFormsModel::get_form_meta($gravity_form_data['id']);
                if (!empty($form_meta)) {
                    $gravityform = RGFormsModel::get_form($gravity_form_data['id']);
                }
            }
            ?>
				<div class="options_group">
					<p class="form-field">
						<label for="gravityform-id"><?php 
            _e('Choose Form', 'wc_gf_addons');
            ?>
</label>
						<?php 
            echo '<select id="gravityform-id" name="gravityform-id"><option value="">' . __('None', 'wc_gf_addons') . '</option>';
            foreach (RGFormsModel::get_forms() as $form) {
                echo '<option ' . selected($form->id, $gravity_form_data['id']) . ' value="' . esc_attr($form->id) . '">' . wptexturize($form->title) . '</option>';
            }
            echo '</select>';
            ?>
					</p>

					<?php 
            woocommerce_wp_checkbox(array('id' => 'gravityform-display_title', 'label' => __('Display Title', 'wc_gf_addons'), 'value' => isset($gravity_form_data['display_title']) && $gravity_form_data['display_title'] ? 'yes' : ''));
            woocommerce_wp_checkbox(array('id' => 'gravityform-display_description', 'label' => __('Display Description', 'wc_gf_addons'), 'value' => isset($gravity_form_data['display_description']) && $gravity_form_data['display_description'] ? 'yes' : ''));
            ?>
				</div>

				<div class="options_group" style="padding: 0 9px;">
			<?php 
            if (!empty($gravityform) && is_object($gravityform)) {
                ?>
						<h4><a href="<?php 
                printf('%s/admin.php?page=gf_edit_forms&id=%d', get_admin_url(), $gravityform->id);
                ?>
" class="edit_gravityform">Edit <?php 
                echo $gravityform->title;
                ?>
 Gravity Form</a></h4>
			<?php 
            }
            ?>
				</div>
			</div>
			<div id="price_labels_data" class="gforms-panel panel woocommerce_options_panel" <?php 
            echo empty($gravity_form_data['id']) ? "style='display:none;'" : '';
            ?>
>
				<h4><?php 
            _e('Price Labels', 'wc_gf_addons');
            ?>
</h4>
				<div class="options_group">
					<?php 
            woocommerce_wp_checkbox(array('id' => 'gravityform-disable_woocommerce_price', 'label' => __('Remove WooCommerce Price?', 'wc_gf_addons'), 'value' => isset($gravity_form_data['disable_woocommerce_price']) ? $gravity_form_data['disable_woocommerce_price'] : ''));
            woocommerce_wp_text_input(array('id' => 'gravityform-price-before', 'label' => __('Price Before', 'wc_gf_addons'), 'value' => isset($gravity_form_data['price_before']) ? $gravity_form_data['price_before'] : '', 'placeholder' => __('Base Price:', 'wc_gf_addons'), 'description' => __('Enter text you would like printed before the price of the product.', 'wc_gf_addons')));
            woocommerce_wp_text_input(array('id' => 'gravityform-price-after', 'label' => __('Price After', 'wc_gf_addons'), 'value' => isset($gravity_form_data['price_after']) ? $gravity_form_data['price_after'] : '', 'placeholder' => __('', 'wc_gf_addons'), 'description' => __('Enter text you would like printed after the price of the product.', 'wc_gf_addons')));
            ?>
				</div>
			</div>
			<div id="total_labels_data" class="gforms-panel panel woocommerce_options_panel" <?php 
            echo empty($gravity_form_data['id']) ? "style='display:none;'" : '';
            ?>
>
				<h4><?php 
            _e('Total Calculations', 'wc_gf_addons');
            ?>
</h4>
				<?php 
            echo '<div class="options_group">';
            woocommerce_wp_checkbox(array('id' => 'gravityform-disable_calculations', 'label' => __('Disable Calculations?', 'wc_gf_addons'), 'value' => isset($gravity_form_data['disable_calculations']) ? $gravity_form_data['disable_calculations'] : ''));
            echo '</div><div class="options_group">';
            woocommerce_wp_checkbox(array('id' => 'gravityform-disable_label_subtotal', 'label' => __('Disable Subtotal?', 'wc_gf_addons'), 'value' => isset($gravity_form_data['disable_label_subtotal']) ? $gravity_form_data['disable_label_subtotal'] : ''));
            woocommerce_wp_text_input(array('id' => 'gravityform-label_subtotal', 'label' => __('Subtotal Label', 'wc_gf_addons'), 'value' => isset($gravity_form_data['label_subtotal']) && !empty($gravity_form_data['label_subtotal']) ? $gravity_form_data['label_subtotal'] : 'Subtotal', 'placeholder' => __('Subtotal', 'wc_gf_addons'), 'description' => __('Enter "Subtotal" label to display on for single products.', 'wc_gf_addons')));
            echo '</div><div class="options_group">';
            woocommerce_wp_checkbox(array('id' => 'gravityform-disable_label_options', 'label' => __('Disable Options Label?', 'wc_gf_addons'), 'value' => isset($gravity_form_data['disable_label_options']) ? $gravity_form_data['disable_label_options'] : ''));
            woocommerce_wp_text_input(array('id' => 'gravityform-label_options', 'label' => __('Options Label', 'wc_gf_addons'), 'value' => isset($gravity_form_data['label_options']) && !empty($gravity_form_data['label_options']) ? $gravity_form_data['label_options'] : 'Options', 'placeholder' => __('Options', 'wc_gf_addons'), 'description' => __('Enter the "Options" label to display for single products.', 'wc_gf_addons')));
            echo '</div><div class="options_group">';
            woocommerce_wp_checkbox(array('id' => 'gravityform-disable_label_total', 'label' => __('Disable Total Label?', 'wc_gf_addons'), 'value' => isset($gravity_form_data['disable_label_total']) ? $gravity_form_data['disable_label_total'] : ''));
            woocommerce_wp_text_input(array('id' => 'gravityform-label_total', 'label' => __('Total Label', 'wc_gf_addons'), 'value' => isset($gravity_form_data['label_total']) && !empty($gravity_form_data['label_total']) ? $gravity_form_data['label_total'] : 'Total', 'placeholder' => __('Total', 'wc_gf_addons'), 'description' => __('Enter the "Total" label to display for single products.', 'wc_gf_addons')));
            echo '</div>';
            ?>
			</div>
			<?php 
        }
Beispiel #27
0
 public static function maybe_process_form()
 {
     $form_id = isset($_POST['gform_submit']) ? absint($_POST['gform_submit']) : 0;
     if ($form_id) {
         $form_info = RGFormsModel::get_form($form_id);
         $is_valid_form = $form_info && $form_info->is_active;
         if ($is_valid_form) {
             require_once GFCommon::get_base_path() . '/form_display.php';
             GFFormDisplay::process_form($form_id);
         }
     } elseif (isset($_POST['gform_send_resume_link'])) {
         require_once GFCommon::get_base_path() . '/form_display.php';
         GFFormDisplay::process_send_resume_link();
     }
 }
 /**
  * Return title of Gravity form
  *
  *
  * @return string
  */
 public static function getFormTitle($form_id)
 {
     $form = RGFormsModel::get_form($form_id);
     return $form->title;
 }