/**
  * Loads the matching meta data for the currently set form id
  * @return boolean true on success and false on failure
  */
 public function load()
 {
     if (!defined('WPINC') || !$this->_post_id || !class_exists('GFAPI')) {
         return false;
     }
     $lead = \GFAPI::get_entry($this->_post_id);
     $form = \GFAPI::get_form($lead['form_id']);
     $values = array();
     foreach ($form['fields'] as $field) {
         if (isset($field["inputs"]) && is_array($field['inputs'])) {
             foreach ($field['inputs'] as $input) {
                 // Extract best label
                 $key = $input['label'] ? $input['label'] : \GFCommon::get_label($field, (string) $input["id"]);
                 // Redundant formatting
                 $key = strtolower(str_replace(array(' '), array('_'), $key));
                 $value = isset($lead[(string) $input['id']]) ? $lead[(string) $input['id']] : "";
                 $values[$key] = htmlentities(stripslashes($value), ENT_QUOTES);
             }
         } elseif (!rgar($field, 'displayOnly')) {
             // Extract best label
             $key = isset($field['adminLabel']) && $field['adminLabel'] != "" ? $field['adminLabel'] : ($field['label'] ? $field['label'] : \GFCommon::get_label($field));
             // More redundant formatting
             $key = strtolower(str_replace(array(' '), array('_'), $key));
             $value = isset($lead[$field['id']]) ? $lead[$field['id']] : "";
             $values[$key] = htmlentities(stripslashes($value), ENT_QUOTES);
         }
     }
     try {
         $this->assign($values);
     } catch (Exception $e) {
         $error = $e->getMessage();
     }
     return true;
 }
 /**
  * Handle requests for form iframes.
  *
  * @since 1.0.0
  */
 public function template_redirect()
 {
     global $wp;
     if (empty($wp->query_vars['gfiframe']) || 'gfembed' != $wp->query_vars['gfiframe'] && 'gfembed.php' != $wp->query_vars['gfiframe']) {
         return;
     }
     $form_id = null;
     if (!empty($_GET['f'])) {
         $form_id = absint($_GET['f']);
     } else {
         // The request needs an 'f' query arg with the form id.
         wp_die(esc_html__('Invalid form id.', 'gravity-forms-iframe'));
     }
     $form = GFFormsModel::get_form_meta($form_id);
     $settings = $this->addon->get_form_settings($form);
     // Make sure the form can be embedded.
     if (empty($settings['is_enabled']) || !$settings['is_enabled']) {
         wp_die(esc_html__('Embedding is disabled for this form.', 'gravity-forms-iframe'));
     }
     // Disable the toolbar in case the form is embedded on the same domain.
     show_admin_bar(false);
     require_once GFCommon::get_base_path() . '/form_display.php';
     // Settings may be overridden in the query string (querystring -> form settings -> default).
     $args = wp_parse_args($_GET, array('dt' => empty($settings['display_title']) ? false : (bool) $settings['display_title'], 'dd' => empty($settings['display_description']) ? false : (bool) $settings['display_description']));
     // @todo Need to convert query string values to boolean.
     $display_title = (bool) $args['dt'];
     $display_description = (bool) $args['dd'];
     unset($args);
     unset($settings);
     // Templates can be customized in parent or child themes.
     $templates = array('gravity-forms-iframe-' . $form_id . '.php', 'gravity-forms-iframe.php');
     $template = gfiframe_locate_template($templates);
     include $template;
     exit;
 }
Exemple #3
0
function output_data($pdf, $lead = array(), $form = array(), $fieldData = array())
{
    $pdf->AddPage();
    $dataArray = array(array('Project ID #', 3, 'text'), array('Project Name', 38, 'text'), array('Name of person responsible for fire safety at your exhibit', 21, 'text'), array('Their Email', 23, 'text'), array('Their Phone', 24, 'text'), array('Description', 37, 'textarea'), array('Describe your fire safety concerns', 19, 'textarea'), array('Describe how you plan to keep your exhibit safe', 27, 'textarea'), array('Who will be assisting at your exhibit to keep it safe', 20, 'text'), array('Placement Requirements', 7, 'textarea'), array('What is burning', 10, 'text'), array('What is the fuel source', 11, 'text'), array('how much is fuel is burning and in what time period', 12, 'textarea'), array('how much fuel will you have at the event, including tank sizes', 13, 'textarea'), array('where and how is the fuel stored', 14, 'text'), array('Does the valve have an electronic propane sniffer', 15, 'text'), array('Other suppression devices', 16, 'textarea'), array('Do you have insurance?', 18, 'text'), array('Additional comments', 28, 'textarea'), array('Are you 18 years or older?', 30, 'text'), array('Signed', 32, 'text'), array('I am the Parent and/or Legal Guardian of', 33, 'text'), array('Date', 34, 'text'));
    $pdf->SetFillColor(190, 210, 247);
    $lineheight = 6;
    foreach ($dataArray as $data) {
        $fieldID = $data[1];
        if (isset($fieldData[$fieldID])) {
            $field = $fieldData[$fieldID];
            $value = RGFormsModel::get_lead_field_value($lead, $field);
            if (RGFormsModel::get_input_type($field) != 'email') {
                $display_value = GFCommon::get_lead_field_display($field, $value);
                $display_value = apply_filters('gform_entry_field_value', $display_value, $field, $lead, $form);
            } else {
                $display_value = $value;
            }
        } else {
            $display_value = '';
        }
        $pdf->MultiCell(0, $lineheight, $data[0] . ': ');
        $pdf->MultiCell(0, $lineheight, $display_value, 0, 'L', true);
        $pdf->Ln();
    }
}
 /**
  * Add pending referral
  *
  * @access public
  * @uses GFFormsModel::get_lead()
  * @uses GFCommon::get_product_fields()
  * @uses GFCommon::to_number()
  *
  * @param array $entry
  * @param array $form
  */
 public function add_pending_referral($entry, $form)
 {
     if ($this->was_referred()) {
         // Do some craziness to determine the price (this should be easy but is not)
         $desc = '';
         $entry = GFFormsModel::get_lead($entry['id']);
         $products = GFCommon::get_product_fields($form, $entry);
         $total = 0;
         foreach ($products['products'] as $key => $product) {
             $desc .= $product['name'];
             if ($key + 1 < count($products)) {
                 $description .= ', ';
             }
             $price = GFCommon::to_number($product['price']);
             if (is_array(rgar($product, 'options'))) {
                 $count = sizeof($product['options']);
                 $index = 1;
                 foreach ($product['options'] as $option) {
                     $price += GFCommon::to_number($option['price']);
                 }
             }
             $subtotal = floatval($product['quantity']) * $price;
             $total += $subtotal;
         }
         $total += floatval($products['shipping']['price']);
         $referral_total = $this->calculate_referral_amount($total, $entry['id']);
         $this->insert_pending_referral($referral_total, $entry['id'], $desc);
     }
 }
Exemple #5
0
 function __construct()
 {
     //load text domains
     GFCommon::load_gf_text_domain('gravityforms');
     $description = esc_html__('Gravity Forms Widget', 'gravityforms');
     WP_Widget::__construct('gform_widget', __('Form', 'gravityforms'), array('classname' => 'gform_widget', 'description' => $description), array('width' => 200, 'height' => 250, 'id_base' => 'gform_widget'));
 }
Exemple #6
0
 /**
  * Acquirrer field input
  *
  * @param string $field_content
  * @param string $field
  * @param string $value
  * @param string $lead_id
  * @param string $form_id
  */
 public static function acquirer_field_input($field_content, $field, $value, $lead_id, $form_id)
 {
     $type = RGFormsModel::get_input_type($field);
     if (Pronamic_WP_Pay_Extensions_GravityForms_IssuerDropDown::TYPE === $type) {
         $id = $field['id'];
         $field_id = IS_ADMIN || 0 === $form_id ? "input_{$id}" : 'input_' . $form_id . "_{$id}";
         $class_suffix = RG_CURRENT_VIEW === 'entry' ? '_admin' : '';
         $size = rgar($field, 'size');
         $class = $size . $class_suffix;
         $css_class = trim(esc_attr($class) . ' gfield_ideal_acquirer_select');
         $tab_index = GFCommon::get_tabindex();
         $disabled_text = IS_ADMIN && 'entry' !== RG_CURRENT_VIEW ? "disabled='disabled'" : '';
         $html = '';
         $feed = get_pronamic_gf_pay_conditioned_feed_by_form_id($form_id, true);
         /**
          * Developing warning:
          * Don't use single quotes in the HTML you output, it is buggy in combination with SACK
          */
         if (IS_ADMIN) {
             if (null === $feed) {
                 $html .= sprintf("<a class='ideal-edit-link' href='%s' target='_blank'>%s</a>", add_query_arg('post_type', 'pronamic_pay_gf', admin_url('post-new.php')), __('Create iDEAL feed', 'pronamic_ideal'));
             } else {
                 $html .= sprintf("<a class='ideal-edit-link' href='%s' target='_blank'>%s</a>", get_edit_post_link($feed->id), __('Edit iDEAL feed', 'pronamic_ideal'));
             }
         }
         $html_input = '';
         $html_error = '';
         if (null !== $feed) {
             $gateway = Pronamic_WP_Pay_Plugin::get_gateway($feed->config_id);
             if ($gateway) {
                 $issuer_field = $gateway->get_issuer_field();
                 $error = $gateway->get_error();
                 if (is_wp_error($error)) {
                     $html_error .= Pronamic_WP_Pay_Plugin::get_default_error_message();
                     $html_error .= '<br /><em>' . $error->get_error_message() . '</em>';
                 } elseif ($issuer_field) {
                     $choices = $issuer_field['choices'];
                     $options = Pronamic_WP_HTML_Helper::select_options_grouped($choices, $value);
                     // Double quotes are not working, se we replace them with an single quote
                     $options = str_replace('"', '\'', $options);
                     $html_input = '';
                     $html_input .= sprintf("<select name='input_%d' id='%s' class='%s' %s %s>", $id, $field_id, $css_class, $tab_index, $disabled_text);
                     $html_input .= sprintf('%s', $options);
                     $html_input .= sprintf('</select>');
                 }
             }
         }
         if ($html_error) {
             $html .= sprintf("<div class='gfield_description validation_message'>");
             $html .= sprintf('%s', $html_error);
             $html .= sprintf('</div>');
         } else {
             $html .= sprintf("<div class='ginput_container ginput_ideal'>");
             $html .= sprintf('%s', $html_input);
             $html .= sprintf('</div>');
         }
         $field_content = $html;
     }
     return $field_content;
 }
 function send_webhook()
 {
     $entry = $this->get_entry();
     $url = $this->url;
     $this->log_debug(__METHOD__ . '() - url before replacing variables: ' . $url);
     $url = GFCommon::replace_variables($url, $this->get_form(), $entry, true, false, false, 'text');
     $this->log_debug(__METHOD__ . '() - url after replacing variables: ' . $url);
     $method = strtoupper($this->method);
     $body = null;
     $headers = array();
     if (in_array($method, array('POST', 'PUT'))) {
         if ($this->format == 'json') {
             $headers = array('Content-type' => 'application/json');
             $body = json_encode($entry);
         } else {
             $headers = array();
             $body = $entry;
         }
     }
     $args = array('method' => $method, 'timeout' => 45, 'redirection' => 3, 'blocking' => true, 'headers' => $headers, 'body' => $body, 'cookies' => array());
     $args = apply_filters('gravityflow_webhook_args', $args, $entry, $this);
     $response = wp_remote_request($url, $args);
     $this->log_debug(__METHOD__ . '() - response: ' . print_r($response, true));
     if (is_wp_error($response)) {
         $step_status = 'error';
     } else {
         $step_status = 'success';
     }
     $note = esc_html__('Webhook sent. Url: ' . $url);
     $this->add_note($note, 0, 'webhook');
     do_action('gravityflow_post_webhook', $response, $args, $entry, $this);
     return $step_status;
 }
 public function get_field_content($value, $force_frontend_label, $form)
 {
     if (is_admin()) {
         $admin_buttons = $this->get_admin_buttons();
         $field_content = "{$admin_buttons}\n\t\t\t\t\t\t\t<div class=\"gf-pagebreak-end gf-pagebreak-container gf-repeater-end\">\n\t\t\t\t\t\t\t\t<div class=\"gf-pagebreak-text-before\">end repeater</div>\n\t\t\t\t\t\t\t\t<div class=\"gf-pagebreak-text-main\"><span>REPEATER</span></div>\n\t\t\t\t\t\t\t\t<div class=\"gf-pagebreak-text-after\">end of repeater</div>\n\t\t\t\t\t\t\t</div>";
     } else {
         $add_html = $this->add;
         $remove_html = $this->remove;
         $hideButtons = $this->hideButtons;
         $tabindex = GFCommon::get_tabindex();
         if (empty($add_html)) {
             $add_html = "<img class=\"gf_repeater_add_default\" alt=\"+\" src=\"data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7\">";
         }
         if (empty($remove_html)) {
             $remove_html = "<img class=\"gf_repeater_remove_default\" alt=\"-\" src=\"data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7\">";
         }
         $field_content = "<div class=\"ginput_container ginput_container_repeater-end\">\n";
         if (!$hideButtons) {
             $field_content .= "<span class=\"gf_repeater_remove\" {$tabindex}>{$remove_html}</span>";
             $field_content .= "<span class=\"gf_repeater_add\" {$tabindex}>{$add_html}</span>";
         }
         $field_content .= "</div>";
     }
     return $field_content;
 }
 public function get_field_input($form, $value = '', $entry = null)
 {
     $form_id = $form['id'];
     $is_entry_detail = $this->is_entry_detail();
     $is_form_editor = $this->is_form_editor();
     $id = (int) $this->id;
     $product_name = !is_array($value) || empty($value[$this->id . '.1']) ? esc_attr($this->label) : esc_attr($value[$this->id . '.1']);
     $price = !is_array($value) || empty($value[$this->id . '.2']) ? $this->basePrice : esc_attr($value[$this->id . '.2']);
     $quantity = is_array($value) ? esc_attr($value[$this->id . '.3']) : '';
     if (rgblank($quantity)) {
         $quantity = 1;
     }
     if (empty($price)) {
         $price = 0;
     }
     $price = esc_attr($price);
     $has_quantity_field = sizeof(GFCommon::get_product_fields_by_type($form, array('quantity'), $this->id)) > 0;
     if ($has_quantity_field) {
         $this->disableQuantity = true;
     }
     $quantity_field = $has_quantity_field ? '' : "<input type='hidden' name='input_{$id}.3' value='" . esc_attr($quantity) . "' id='ginput_quantity_{$form_id}_{$this->id}' class='gform_hidden' />";
     $product_name_field = "<input type='hidden' name='input_{$id}.1' value='{$product_name}' class='gform_hidden' />";
     $disabled_text = $is_form_editor ? 'disabled="disabled"' : '';
     $field_type = $is_entry_detail || $is_form_editor ? 'text' : 'hidden';
     return $quantity_field . $product_name_field . "<input name='input_{$id}.2' id='ginput_base_price_{$form_id}_{$this->id}' type='{$field_type}' value='{$price}' class='gform_hidden ginput_amount' {$disabled_text}/>";
 }
Exemple #10
0
function print_tooltip_scripts()
{
    wp_enqueue_style('gform_tooltip', GFCommon::get_base_url() . '/css/tooltip.css', null, GFCommon::$version);
    wp_enqueue_style('gform_font_awesome', GFCommon::get_base_url() . '/css/font-awesome.css', null, GFCommon::$version);
    wp_print_scripts('gform_tooltip_init');
    wp_print_styles('gform_tooltip', 'gform_font_awesome');
}
 /**
  * Add pending referral
  *
  * @access public
  * @uses GFFormsModel::get_lead()
  * @uses GFCommon::get_product_fields()
  * @uses GFCommon::to_number()
  *
  * @param array $entry
  * @param array $form
  */
 public function add_pending_referral($entry, $form)
 {
     if (!$this->was_referred() || !rgar($form, 'affwp_allow_referrals')) {
         return;
     }
     // Do some craziness to determine the price (this should be easy but is not)
     $desc = isset($form['title']) ? $form['title'] : '';
     $entry = GFFormsModel::get_lead($entry['id']);
     $products = GFCommon::get_product_fields($form, $entry);
     $total = 0;
     foreach ($products['products'] as $key => $product) {
         $price = GFCommon::to_number($product['price']);
         if (is_array(rgar($product, 'options'))) {
             $count = sizeof($product['options']);
             $index = 1;
             foreach ($product['options'] as $option) {
                 $price += GFCommon::to_number($option['price']);
             }
         }
         $subtotal = floatval($product['quantity']) * $price;
         $total += $subtotal;
     }
     // replace description if there are products
     if (!empty($products['products'])) {
         $product_names = wp_list_pluck($products['products'], 'name');
         $desc = implode(', ', $product_names);
     }
     $total += floatval($products['shipping']['price']);
     $referral_total = $this->calculate_referral_amount($total, $entry['id']);
     $this->insert_pending_referral($referral_total, $entry['id'], $desc);
     if (empty($total)) {
         $this->mark_referral_complete($entry, array());
     }
 }
 function process()
 {
     $this->log_debug(__METHOD__ . '(): starting');
     if (class_exists('GFPDF_Core')) {
         global $gfpdf;
         if (empty($gfpdf)) {
             $gfpdf = new GFPDF_Core();
         }
     }
     $entry = $this->get_entry();
     $form = $this->get_form();
     foreach ($form['notifications'] as $notification) {
         $notification_id = $notification['id'];
         $setting_key = 'notification_id_' . $notification_id;
         if ($this->{$setting_key}) {
             if (!GFCommon::evaluate_conditional_logic(rgar($notification, 'conditionalLogic'), $form, $entry)) {
                 $this->log_debug(__METHOD__ . "(): Notification conditional logic not met, not processing notification (#{$notification_id} - {$notification['name']}).");
                 continue;
             }
             GFCommon::send_notification($notification, $form, $entry);
             $this->log_debug(__METHOD__ . "(): Notification sent (#{$notification_id} - {$notification['name']}).");
             $note = sprintf(esc_html__('Sent Notification: %s', 'gravityflow'), $notification['name']);
             $this->add_note($note);
         }
     }
     $this->send_workflow_notification();
     return true;
 }
Exemple #13
0
 /**
  * @since 1.7.5
  */
 function add_hooks()
 {
     // If Gravity Forms isn't active or compatibile, stop loading
     if (false === GravityView_Compatibility::is_valid()) {
         return;
     }
     // Migrate Class
     require_once GRAVITYVIEW_DIR . 'includes/class-migrate.php';
     // Don't load tooltips if on Gravity Forms, otherwise it overrides translations
     if (!GFForms::is_gravity_page()) {
         require_once GFCommon::get_base_path() . '/tooltips.php';
     }
     require_once GRAVITYVIEW_DIR . 'includes/admin/metaboxes/class-gravityview-admin-metaboxes.php';
     require_once GRAVITYVIEW_DIR . 'includes/admin/entry-list.php';
     require_once GRAVITYVIEW_DIR . 'includes/class-change-entry-creator.php';
     /** @since 1.6 */
     require_once GRAVITYVIEW_DIR . 'includes/class-gravityview-admin-duplicate-view.php';
     // Filter Admin messages
     add_filter('post_updated_messages', array($this, 'post_updated_messages'));
     add_filter('bulk_post_updated_messages', array($this, 'post_updated_messages'));
     add_filter('plugin_action_links_' . plugin_basename(GRAVITYVIEW_FILE), array($this, 'plugin_action_links'));
     add_action('plugins_loaded', array($this, 'backend_actions'), 100);
     //Hooks for no-conflict functionality
     add_action('wp_print_scripts', array($this, 'no_conflict_scripts'), 1000);
     add_action('admin_print_footer_scripts', array($this, 'no_conflict_scripts'), 9);
     add_action('wp_print_styles', array($this, 'no_conflict_styles'), 1000);
     add_action('admin_print_styles', array($this, 'no_conflict_styles'), 11);
     add_action('admin_print_footer_scripts', array($this, 'no_conflict_styles'), 1);
     add_action('admin_footer', array($this, 'no_conflict_styles'), 1);
 }
 /**
  * Check for merge tags before passing to Gravity Forms to improve speed.
  *
  * GF doesn't check for whether `{` exists before it starts diving in. They not only replace fields, they do `str_replace()` on things like ip address, which is a lot of work just to check if there's any hint of a replacement variable.
  *
  * We check for the basics first, which is more efficient.
  *
  * @since 1.8.4 - Moved to GravityView_Merge_Tags
  * @since 1.15.1 - Add support for $url_encode and $esc_html arguments
  *
  * @param  string      $text       Text to replace variables in
  * @param  array      $form        GF Form array
  * @param  array      $entry        GF Entry array
  * @param  bool       $url_encode   Pass return value through `url_encode()`
  * @param  bool       $esc_html     Pass return value through `esc_html()`
  * @return string                  Text with variables maybe replaced
  */
 public static function replace_variables($text, $form = array(), $entry = array(), $url_encode = false, $esc_html = true)
 {
     /**
      * @filter `gravityview_do_replace_variables` Turn off merge tag variable replacements.\n
      * Useful where you want to process variables yourself. We do this in the Math Extension.
      * @since 1.13
      * @param[in,out] boolean $do_replace_variables True: yes, replace variables for this text; False: do not replace variables.
      * @param[in] string $text       Text to replace variables in
      * @param[in]  array      $form        GF Form array
      * @param[in]  array      $entry        GF Entry array
      */
     $do_replace_variables = apply_filters('gravityview/merge_tags/do_replace_variables', true, $text, $form, $entry);
     if (strpos($text, '{') === false || !$do_replace_variables) {
         return $text;
     }
     /**
      * Replace GravityView merge tags before going to Gravity Forms
      * This allows us to replace our tags first.
      * @since 1.15
      */
     $text = self::replace_gv_merge_tags($text, $form, $entry);
     // Check for fields - if they exist, we let Gravity Forms handle it.
     preg_match_all('/{[^{]*?:(\\d+(\\.\\d+)?)(:(.*?))?}/mi', $text, $matches, PREG_SET_ORDER);
     if (empty($matches)) {
         // Check for form variables
         if (!preg_match('/\\{(all_fields(:(.*?))?|all_fields_display_empty|pricing_fields|form_title|entry_url|ip|post_id|admin_email|post_edit_url|form_id|entry_id|embed_url|date_mdy|date_dmy|embed_post:(.*?)|custom_field:(.*?)|user_agent|referer|gv:(.*?)|get:(.*?)|user:(.*?)|created_by:(.*?))\\}/ism', $text)) {
             return $text;
         }
     }
     return GFCommon::replace_variables($text, $form, $entry, $url_encode, $esc_html);
 }
 public function render_frontend($widget_args, $content = '', $context = '')
 {
     if (!$this->pre_render_frontend()) {
         return;
     }
     if (!empty($widget_args['title'])) {
         echo $widget_args['title'];
     }
     // Make sure the class is loaded in DataTables
     if (!class_exists('GFFormDisplay')) {
         include_once GFCommon::get_base_path() . '/form_display.php';
     }
     $widget_args['content'] = trim(rtrim($widget_args['content']));
     // No custom content
     if (empty($widget_args['content'])) {
         do_action('gravityview_log_debug', sprintf('%s[render_frontend]: No content.', get_class($this)));
         return;
     }
     // Add paragraphs?
     if (!empty($widget_args['wpautop'])) {
         $widget_args['content'] = wpautop($widget_args['content']);
     }
     // Enqueue scripts needed for Gravity Form display, if form shortcode exists.
     // Also runs `do_shortcode()`
     $content = GFCommon::gform_do_shortcode($widget_args['content']);
     // Add custom class
     $class = !empty($widget_args['custom_class']) ? $widget_args['custom_class'] : '';
     $class = gravityview_sanitize_html_class($class);
     echo '<div class="gv-widget-custom-content ' . $class . '">' . $content . '</div>';
 }
 /**
  * Get the default date format for a field based on the field ID and the time format setting
  *
  * @since 1.16.4
  * @param string $date_format The Gravity Forms date format for the field. Default: "mdy"
  * @param int $field_id The ID of the field. Used to figure out full date/day/month/year
  *
  * @return string PHP date format for the date
  */
 public static function date_display($value = '', $date_format = 'mdy', $field_id = 0)
 {
     // Let Gravity Forms figure out, based on the date format, what day/month/year values are.
     $parsed_date = GFCommon::parse_date($value, $date_format);
     // Are we displaying an input or the whole field?
     $field_input_id = gravityview_get_input_id_from_id($field_id);
     $date_field_output = '';
     switch ($field_input_id) {
         case 1:
             $date_field_output = rgar($parsed_date, 'day');
             break;
         case 2:
             $date_field_output = rgar($parsed_date, 'month');
             break;
         case 3:
             $date_field_output = rgar($parsed_date, 'year');
             break;
     }
     /**
      * @filter `gravityview_date_format` Whether to override the Gravity Forms date format with a PHP date format
      * @see https://codex.wordpress.org/Formatting_Date_and_Time
      * @param null|string Date Format (default: $field->dateFormat)
      */
     $full_date_format = apply_filters('gravityview_date_format', $date_format);
     $full_date = GFCommon::date_display($value, $full_date_format);
     // If the field output is empty, use the full date.
     // Note: The output might be empty because $parsed_date didn't parse correctly.
     return '' === $date_field_output ? $full_date : $date_field_output;
 }
function acf_repeater_population($form)
{
    GFCommon::log_debug("acf_repeater_population() function called for form {$form['id']}");
    // filters are applied only to form ID 4.  Change to your form ID
    foreach ($form['fields'] as &$field) {
        // if the field is not a radio button type or it does not have the CSS Class Name required, continue
        if ('radio' != $field->type || false === strpos($field->cssClass, 'dates_from_acf')) {
            continue;
        }
        // start with an empty choices array
        $field->choices = array();
        // need the ID of the current post
        global $post;
        GFCommon::log_debug("global post =>" . print_r($post, true));
        $rows = get_field('coursedates');
        if ($rows) {
            GFCommon::log_debug("get_field() for coursedates: \$rows => " . print_r($rows, 1));
            foreach ($rows as $row) {
                $city = $row['city'];
                $text = date_i18n('l j. F Y', strtotime($row['startdate'])) . " - " . $city;
                $field->choices[] = array('text' => $text, 'value' => $row['startdate'] . " - " . $city);
            }
        } else {
            $field->choices[] = array('text' => 'Ingen ledige datoer', 'value' => 'Ingen ledige datoer');
        }
        break;
    }
    // always return the form
    return $form;
}
Exemple #18
0
function output_data($pdf, $lead = array(), $form = array(), $fieldData = array())
{
    $pdf->AddPage();
    $dataArray = array(array('Project ID #', 3), array('Project Name', 28), array('Name of person responsible for fire safety at your exhibit', 5), array('Their Email', 15), array('Their phone', 16), array('Description', 19), array('Describe your safety concerns', 12), array('Describe how you plan to keep your exhibit safe', 20), array('Who will be assisting at your exhibit to keep it safe', 11), array('Placement Requirements', 7), array('Do you have Insurance', 9), array('Additional Comments', 13), array('Are you 18 years or older?', 23), array('Signed', 25), array('I am the Parent and/or Legal Guardian of', 26), array('Date', 27));
    $pdf->SetFillColor(190, 210, 247);
    $lineheight = 6;
    foreach ($dataArray as $data) {
        $fieldID = $data[1];
        if (isset($fieldData[$fieldID])) {
            $field = $fieldData[$fieldID];
            $value = RGFormsModel::get_lead_field_value($lead, $field);
            if (RGFormsModel::get_input_type($field) != 'email') {
                $display_value = GFCommon::get_lead_field_display($field, $value);
                $display_value = apply_filters('gform_entry_field_value', $display_value, $field, $lead, $form);
            } else {
                $display_value = $value;
            }
        } else {
            $display_value = '';
        }
        $pdf->MultiCell(0, $lineheight, $data[0] . ': ');
        $pdf->MultiCell(0, $lineheight, $display_value, 0, 'L', true);
        $pdf->Ln();
    }
}
 function setUp()
 {
     parent::setUp();
     $this->AJAX = new GravityView_Ajax();
     $this->create_test_nonce();
     $this->GravityView_Preset_Business_Data = new GravityView_Preset_Business_Data();
     require_once GFCommon::get_base_path() . '/export.php';
 }
Exemple #20
0
function print_tooltip_scripts()
{
    wp_register_script('qtip-lib', GFCommon::get_base_url() . "/js/jquery.qtip-1.0.0-rc2.min.js", null, GFCommon::$version);
    wp_enqueue_script('qtip-init', GFCommon::get_base_url() . "/js/qtip_init.js", array('qtip-lib'), GFCommon::$version);
    wp_enqueue_style("gf_tooltip", GFCommon::get_base_url() . "/css/tooltip.css", null, GFCommon::$version);
    wp_print_scripts();
    wp_print_styles();
}
 function column_is_active($item)
 {
     $is_active = intval(rgar($item, "is_active"));
     $src = GFCommon::get_base_url() . "/images/active{$is_active}.png";
     $title = $is_active ? __("Active", "gravityforms") : __("Inactive", "gravityforms");
     $img = sprintf("<img src=\"{$src}\" class=\"toggle_active\" title=\"{$title}\" data-feed-id=\"%s\" style=\"cursor:pointer\";/>", $item['id']);
     return $img;
 }
Exemple #22
0
function print_tooltip_scripts()
{
    $min = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG || isset($_GET['gform_debug']) ? '' : '.min';
    wp_enqueue_style('gform_tooltip', GFCommon::get_base_url() . "/css/tooltip{$min}.css", null, GFCommon::$version);
    wp_enqueue_style('gform_font_awesome', GFCommon::get_base_url() . "/css/font-awesome{$min}.css", null, GFCommon::$version);
    wp_print_scripts('gform_tooltip_init');
    wp_print_styles('gform_tooltip', 'gform_font_awesome');
}
function add_column_render($field_container, $field, $form, $css_class, $style, $field_content)
{
    // only modify column_break field
    if (IS_ADMIN || $field['type'] !== 'column_break') {
        return $field_container;
    }
    $ul_classes = GFCommon::get_ul_classes($form) . ' ' . $field['cssClass'];
    return '</ul><ul class="' . $ul_classes . '">';
}
 /**
  * Verifies the hash for the download.
  *
  * @param int $form_id
  * @param int $field_id
  * @param string $file
  * @param string $hash
  *
  * @return bool
  */
 private static function validate_download($form_id, $field_id, $file, $hash)
 {
     if (empty($hash)) {
         return false;
     }
     $hash_check = GFCommon::generate_download_hash($form_id, $field_id, $file);
     $valid = hash_equals($hash, $hash_check);
     return $valid;
 }
function bb_click_array_field_input($input, $field, $value, $lead_id, $form_id)
{
    if ($field["type"] == "bb_click_array") {
        $field_id = IS_ADMIN || $form_id == 0 ? "input_{$id}" : "input_" . $form_id . "_{$id}";
        $input_name = $form_id . '_' . $field["id"];
        $css = isset($field['cssClass']) ? $field['cssClass'] : "";
        $disabled_text = IS_ADMIN && RG_CURRENT_VIEW != "entry" ? "disabled='disabled'" : "";
        $amount = '';
        $clicked = '';
        if (is_array($value)) {
            $amount = esc_attr(rgget($field["id"] . ".1", $value));
            $clicked = rgget($field["id"] . ".5", $value);
        }
        $html = "<div id='{$field_id}' class='ginput_container bb-click-array-" . count($field['choices']) . " " . esc_attr($css) . "'>" . "\n";
        if (is_array($field["choices"])) {
            $choice_id = 0;
            $tabindex = GFCommon::get_tabindex();
            foreach ($field["choices"] as $choice) {
                $id = $field["id"] . '_' . $choice_id;
                $field_value = !empty($choice["value"]) || rgar($field, "enableChoiceValue") ? $choice["value"] : $choice["text"];
                if (rgblank($amount) && RG_CURRENT_VIEW != "entry") {
                    $active = rgar($choice, "isSelected") ? "checked='checked'" : "";
                } else {
                    $active = RGFormsModel::choice_value_match($field, $choice, $amount) ? "checked='checked'" : "";
                }
                if ($active) {
                    $amount = $field_value;
                }
                $field_class = $active ? 's-active' : 's-passive';
                if (rgar($field, 'field_bb_click_array_is_product')) {
                    require_once GFCommon::get_base_path() . '/currency.php';
                    $currency = new RGCurrency(GFCommon::get_currency());
                    $field_value = $currency->to_money($field_value);
                    $field_class .= ' s-currency';
                }
                $html .= sprintf('<div data-clickarray-value="%s" data-choice-id="%s" class="s-html-wrapper %s" id="%s">', esc_attr($field_value), $choice_id, $field_class, $id);
                $html .= sprintf('<div class="s-html-value">%s</div>', $field_value);
                $html .= sprintf("<label for='choice_%s' id='label_%s'>%s</label>", $id, $id, $choice["text"]);
                $html .= '</div>';
                $choice_id++;
            }
            $onblur = !IS_ADMIN ? 'if(jQuery(this).val().replace(" ", "") == "") { jQuery(this).val("' . $other_default_value . '"); }' : '';
            $onkeyup = empty($field["conditionalLogicFields"]) || IS_ADMIN ? '' : "onchange='gf_apply_rules(" . $field["formId"] . "," . GFCommon::json_encode($field["conditionalLogicFields"]) . ");' onkeyup='clearTimeout(__gf_timeout_handle); __gf_timeout_handle = setTimeout(\"gf_apply_rules(" . $field["formId"] . "," . GFCommon::json_encode($field["conditionalLogicFields"]) . ")\", 300);'";
            $value_exists = RGFormsModel::choices_value_match($field, $field["choices"], $value);
            $other_label = empty($field['field_bb_click_array_other_label']) ? 'My Best Gift' : $field['field_bb_click_array_other_label'];
            $other_class = rgar($field, 'enableOtherChoice') ? '' : 'hide';
            $html .= "<label for='input_{$field["formId"]}_{$field["id"]}_1' class='ginput_bb_click_array_other_label " . $other_class . "'>" . $other_label . "</label>";
            $other_class .= rgar($field, 'field_bb_click_array_is_product') ? ' ginput_amount gfield_price gfield_price_' . $field['formId'] . '_' . $field['id'] . '_1 gfield_product_' . $field['formId'] . '_' . $field['id'] . '_1' : '';
            $html .= "<input id='input_{$field["formId"]}_{$field["id"]}_1' name='input_{$field["id"]}_1' type='text' value='" . esc_attr($amount) . "' class='ginput_bb ginput_click_array_other " . $other_class . " " . $field['size'] . "' onblur='{$onblur}' {$tabindex} {$onkeyup} {$disabled_text}>";
            $html .= "<input id='input_{$field["formId"]}_{$field["id"]}_5' name='input_{$field["id"]}_5' type='hidden' value='" . esc_attr($clicked) . "' class='ginput_bb ginput_click_array_clicked'>";
        }
        $html .= "</div>";
        return $html;
    }
    return $input;
}
 /**
  * Check if the form has a text field with a Custom CSS Class that contains 'helpscout-docs'
  *
  * @param array $form
  *
  * @return bool True: yes, it does. False: nope.
  */
 private function has_docs_field($form)
 {
     $text_fields = GFCommon::get_fields_by_type($form, 'text');
     foreach ($text_fields as $text_field) {
         if (strpos(rgar($text_field, 'cssClass'), self::field_css_class) !== false) {
             return true;
         }
     }
     return false;
 }
 public function get_field_input($form, $value = '', $entry = null)
 {
     $is_entry_detail = $this->is_entry_detail();
     $is_form_editor = $this->is_form_editor();
     $content = $is_entry_detail || $is_form_editor ? "<div class='gf-html-container'><span class='gf_blockheader'>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<i class='fa fa-code fa-lg'></i> " . __('HTML Content', 'gravityforms') . '</span><span>' . __('This is a content placeholder. HTML content is not displayed in the form admin. Preview this form to view the content.', 'gravityforms') . '</span></div>' : $this->content;
     $content = GFCommon::replace_variables_prepopulate($content);
     // adding support for merge tags
     $content = do_shortcode($content);
     // adding support for shortcodes
     return $content;
 }
 /**
  * When the widget View is changed, update the Merge Tag data
  *
  * @since 1.6
  */
 function ajax_get_view_merge_tag_data()
 {
     if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'gravityview_ajax_widget')) {
         exit(false);
     }
     $form_id = gravityview_get_form_id($_POST['view_id']);
     $form = RGFormsModel::get_form_meta($form_id);
     $output = array('form' => array('id' => $form['id'], 'title' => $form['title'], 'fields' => $form['fields']), 'mergeTags' => GFCommon::get_merge_tags($form['fields'], '', false));
     echo json_encode($output);
     exit;
 }
 public function get_value_save_entry($value, $form, $input_name, $lead_id, $lead)
 {
     // ignore submitted value and recalculate price in backend
     list($prefix, $field_id, $input_id) = rgexplode('_', $input_name, 3);
     if ($input_id == 2) {
         require_once GFCommon::get_base_path() . '/currency.php';
         $currency = new RGCurrency(GFCommon::get_currency());
         $lead = empty($lead) ? RGFormsModel::get_lead($lead_id) : $lead;
         $value = $currency->to_money(GFCommon::calculate($this, $form, $lead));
     }
     return $value;
 }
function GFUEA_custom_notification_attachments($notification, $form, $entry)
{
    $log = 'rw_notification_attachments() - ';
    GFCommon::log_debug($log . 'starting.');
    #    mail("*****@*****.**","Notification Fire" . date("Y-m-d h:i:s"), print_r($notification, true) . print_r($form,true) . print_r($entry,true));
    if (substr($notification["name"], -5) == "GFUEA") {
        //mail("*****@*****.**","Notification Fire" . date("Y-m-d h:i:s"), print_r($notification, true) . print_r($form,true) . print_r($entry,true));
        $fileupload_fields = GFCommon::get_fields_by_type($form, array('fileupload'));
        if (!is_array($fileupload_fields)) {
            return $notification;
        }
        $attachments = array();
        $upload_root = RGFormsModel::get_upload_root();
        foreach ($fileupload_fields as $field) {
            $url = $entry[$field['id']];
            if (empty($url)) {
                continue;
            } elseif ($field['multipleFiles']) {
                $uploaded_files = json_decode(stripslashes($url), true);
                $zip = new ZipArchive();
                //$filetext = date("Y-m-d his");
                $filename = $upload_root . "/uploaded_files" . $entry['id'] . ".zip";
                if ($zip->open($filename, ZipArchive::CREATE) !== TRUE) {
                    foreach ($uploaded_files as $uploaded_file) {
                        $attachment = preg_replace('|^(.*?)/gravity_forms/|', $upload_root, $uploaded_file);
                        GFCommon::log_debug($log . 'attaching the file: ' . print_r($attachment, true));
                        $attachments[] = $attachment;
                    }
                } else {
                    foreach ($uploaded_files as $uploaded_file) {
                        $attachment = preg_replace('|^(.*?)/gravity_forms/|', $upload_root, $uploaded_file);
                        GFCommon::log_debug($log . 'attaching the file: ' . print_r($attachment, true));
                        $new_filename = substr($attachment, strrpos($attachment, '/') + 1);
                        $zip->addFile($attachment, $new_filename);
                        //$attachments[] = $attachment;
                    }
                    $zip->close();
                    $attachments[] = $filename;
                    add_filter('gform_confirmation', 'gfuea_clean_zips', 10, 4);
                }
            } else {
                $attachment = preg_replace('|^(.*?)/gravity_forms/|', $upload_root, $url);
                GFCommon::log_debug($log . 'attaching the file: ' . print_r($attachment, true));
                $attachments[] = $attachment;
            }
        }
        $notification['attachments'] = $attachments;
    }
    //mail("*****@*****.**","Notification Fire" . date("Y-m-d h:i:s"), "Attach IDs:\n" . print_r($attachIds, true) . "\nNotification:\n" . print_r($notification, true) . "\nForm:\n" .print_r($form,true) . "\nEntry:\n" .print_r($entry,true));
    GFCommon::log_debug($log . 'stopping.');
    return $notification;
}