Пример #1
1
/**
 * Get all available gravity forms
 */
function crb_get_forms()
{
    $forms = array();
    if (!class_exists('RGFormsModel')) {
        return;
    }
    $available_forms = RGFormsModel::get_forms(null, 'title');
    foreach ($available_forms as $form) {
        $forms[$form->id] = $form->title;
    }
    return $forms;
}
Пример #2
0
 /**
  * Check if the iDEAL condition is true
  *
  * @param mixed $form
  * @param mixed $feed
  */
 public static function is_condition_true($form, $feed)
 {
     if (!$feed->condition_enabled) {
         return true;
     }
     $field = RGFormsModel::get_field($form, $feed->condition_field_id);
     // Unknown field
     if (empty($field)) {
         return true;
     }
     $is_hidden = RGFormsModel::is_field_hidden($form, $field, array());
     // Ignore condition if the field is hidden
     if ($is_hidden) {
         return false;
     }
     $value = RGFormsModel::get_field_value($field, array());
     $is_match = RGFormsModel::is_value_match($value, $feed->condition_value);
     switch ($feed->condition_operator) {
         case Pronamic_WP_Pay_Extensions_GravityForms_GravityForms::OPERATOR_IS:
             $result = $is_match;
             break;
         case Pronamic_WP_Pay_Extensions_GravityForms_GravityForms::OPERATOR_IS_NOT:
             $result = !$is_match;
             break;
         default:
             $result = true;
     }
     return $result;
 }
 /**
  * Update the post categories based on all post category fields
  *
  * @since 1.17
  *
  * @param array $form Gravity Forms form array
  * @param int $entry_id Numeric ID of the entry that was updated
  *
  * @return array|false|WP_Error Array of term taxonomy IDs of affected categories. WP_Error or false on failure. false if there are no post category fields or connected post.
  */
 public function set_post_categories($form = array(), $entry_id = 0)
 {
     $entry = GFAPI::get_entry($entry_id);
     $post_id = rgar($entry, 'post_id');
     if (empty($post_id)) {
         return false;
     }
     $return = false;
     $post_category_fields = GFAPI::get_fields_by_type($form, 'post_category');
     if ($post_category_fields) {
         $updated_categories = array();
         foreach ($post_category_fields as $field) {
             // Get the value of the field, including $_POSTed value
             $field_cats = RGFormsModel::get_field_value($field);
             $field_cats = is_array($field_cats) ? array_values($field_cats) : (array) $field_cats;
             $field_cats = gv_map_deep($field_cats, 'intval');
             $updated_categories = array_merge($updated_categories, array_values($field_cats));
         }
         // Remove `0` values from intval()
         $updated_categories = array_filter($updated_categories);
         /**
          * @filter `gravityview/edit_entry/post_categories/append` Should post categories be added to or replaced?
          * @since 1.17
          * @param bool $append If `true`, don't delete existing categories, just add on. If `false`, replace the categories with the submitted categories. Default: `false`
          */
         $append = apply_filters('gravityview/edit_entry/post_categories/append', false);
         $return = wp_set_post_categories($post_id, $updated_categories, $append);
     }
     return $return;
 }
Пример #4
0
function partners_sub_page_metaboxes()
{
    $prefix = '_partners_page_';
    $options[0] = 'Please select...';
    if (class_exists('RGFormsModel')) {
        foreach (RGFormsModel::get_forms(null, 'title') as $form) {
            $options[$form->id] = $form->title;
        }
    }
    /**
     * Initiate the metabox
     */
    $cmb = new_cmb2_box(array('id' => 'partners_page_form_meta', 'title' => __('Partners Page Form', 'cmb2'), 'object_types' => array('page'), 'context' => 'normal', 'priority' => 'high', 'show_names' => true, 'show_on' => array('key' => 'page-template', 'value' => 'templates/partners.php')));
    // Regular text field
    $cmb->add_field(array('name' => __('Pick a Form', 'cmb2'), 'id' => $prefix . 'form_dropdown', 'type' => 'select', 'options' => $options));
    /**
     * Initiate the metabox
     */
    $cmb = new_cmb2_box(array('id' => 'partners_page_file_meta', 'title' => __('Partners Page File Downloads', 'cmb2'), 'object_types' => array('page'), 'context' => 'normal', 'priority' => 'high', 'show_names' => true, 'show_on' => array('key' => 'page-template', 'value' => 'templates/partners.php')));
    $group_field_id = $cmb->add_field(array('id' => 'partners_file_download_group', 'type' => 'group', 'options' => array('group_title' => __('File {#}', 'cmb2'), 'add_button' => __('Add Another File', 'cmb2'), 'remove_button' => __('Remove File', 'cmb2'), 'sortable' => true)));
    // Id's for group's fields only need to be unique for the group. Prefix is not needed.
    $cmb->add_group_field($group_field_id, array('name' => 'File Title', 'id' => 'title', 'type' => 'text'));
    $cmb->add_group_field($group_field_id, array('name' => 'File Upload', 'id' => 'link', 'type' => 'file'));
    $cmb->add_group_field($group_field_id, array('name' => 'File Image', 'id' => 'image', 'type' => 'file'));
}
 function setup_entry($post_entry)
 {
     // echo "post array <br>";
     // print_r($post_entry);
     // echo "<br><br>";
     // echo "loading and ids <br><br>";
     $return = array();
     $return['form_id'] = $post_entry['form_id'];
     $form = RGFormsModel::get_form_meta($post_entry['form_id']);
     // $counter=0;
     // filter array entry with no sub content ex: 1,2,3,4,5,6,7,8
     foreach ($form['fields'] as $field) {
         // $counter++;
         $post_entry_key = 'input_' . $field['id'];
         // echo "$counter .) " . $field['id']  . ' = ' . $post_entry[$post_entry_key] . " <br>";
         if (array_key_exists($post_entry_key, $post_entry)) {
             $return[$field['id']] = $post_entry[$post_entry_key];
         }
     }
     //filter array entry with sub content ex: 200.1, 299.2, 323.3
     $entrySub1 = getEntrySub1($post_entry);
     foreach ($entrySub1 as $entryId) {
         $post_entry_key = 'input_' . $entryId;
         if (array_key_exists($post_entry_key, $post_entry)) {
             $return[$entryId] = $post_entry[$post_entry_key];
         }
     }
     return $return;
 }
Пример #6
0
 /**
  * Returns the field input.
  *
  * @param array $form
  * @param string $value
  * @param null|array $entry
  *
  * @return string
  */
 public function get_field_input($form, $value = '', $entry = null)
 {
     if (is_array($value)) {
         $value = '';
     }
     $is_entry_detail = $this->is_entry_detail();
     $is_form_editor = $this->is_form_editor();
     $form_id = $form['id'];
     $id = intval($this->id);
     $field_id = $is_entry_detail || $is_form_editor || $form_id == 0 ? "input_{$id}" : 'input_' . $form_id . "_{$id}";
     $size = $this->size;
     $disabled_text = $is_form_editor ? "disabled='disabled'" : '';
     $class_suffix = $is_entry_detail ? '_admin' : '';
     $class = $size . $class_suffix;
     $instruction_div = '';
     if ($this->failed_validation) {
         $phone_format = $this->get_phone_format();
         if (rgar($phone_format, 'instruction')) {
             $instruction_div = sprintf("<div class='instruction validation_message'>%s %s</div>", esc_html__('Phone format:', 'gravityforms'), $phone_format['instruction']);
         }
     }
     $html_input_type = RGFormsModel::is_html5_enabled() ? 'tel' : 'text';
     $logic_event = $this->get_conditional_logic_event('keyup');
     $placeholder_attribute = $this->get_field_placeholder_attribute();
     $required_attribute = $this->isRequired ? 'aria-required="true"' : '';
     $invalid_attribute = $this->failed_validation ? 'aria-invalid="true"' : 'aria-invalid="false"';
     $tabindex = $this->get_tabindex();
     return sprintf("<div class='ginput_container ginput_container_phone'><input name='input_%d' id='%s' type='{$html_input_type}' value='%s' class='%s' {$tabindex} {$logic_event} {$placeholder_attribute} {$required_attribute} {$invalid_attribute} %s/>{$instruction_div}</div>", $id, $field_id, esc_attr($value), esc_attr($class), $disabled_text);
 }
Пример #7
0
 public function run($arguments)
 {
     if (class_exists('RGFormsModel') && is_callable(array('RGFormsModel', 'get_forms'))) {
         return RGFormsModel::get_forms();
     }
     return false;
 }
Пример #8
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();
    }
}
Пример #9
0
 public function get_value_merge_tag($value, $input_id, $entry, $form, $modifier, $raw_value, $url_encode, $esc_html, $format, $nl2br)
 {
     $use_value = $modifier == 'value';
     $use_price = in_array($modifier, array('price', 'currency'));
     $format_currency = $modifier == 'currency';
     if (is_array($raw_value) && (string) intval($input_id) != $input_id) {
         $items = array($input_id => $value);
         //float input Ids. (i.e. 4.1 ). Used when targeting specific checkbox items
     } elseif (is_array($raw_value)) {
         $items = $raw_value;
     } else {
         $items = array($input_id => $raw_value);
     }
     $ary = array();
     foreach ($items as $input_id => $item) {
         if ($use_value) {
             list($val, $price) = rgexplode('|', $item, 2);
         } elseif ($use_price) {
             list($name, $val) = rgexplode('|', $item, 2);
             if ($format_currency) {
                 $val = GFCommon::to_money($val, rgar($entry, 'currency'));
             }
         } elseif ($this->type == 'post_category') {
             $use_id = strtolower($modifier) == 'id';
             $item_value = GFCommon::format_post_category($item, $use_id);
             $val = RGFormsModel::is_field_hidden($form, $this, array(), $entry) ? '' : $item_value;
         } else {
             $val = RGFormsModel::is_field_hidden($form, $this, array(), $entry) ? '' : RGFormsModel::get_choice_text($this, $raw_value, $input_id);
         }
         $ary[] = GFCommon::format_variable_value($val, $url_encode, $esc_html, $format);
     }
     return GFCommon::implode_non_blank(', ', $ary);
 }
Пример #10
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;
 }
Пример #11
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();
    }
}
function gform_column_splits($content, $field, $value, $lead_id, $form_id)
{
    if (IS_ADMIN) {
        return $content;
    }
    // only modify HTML on the front end
    $form = RGFormsModel::get_form_meta($form_id, true);
    $form_class = array_key_exists('cssClass', $form) ? $form['cssClass'] : '';
    $form_classes = preg_split('/[\\n\\r\\t ]+/', $form_class, -1, PREG_SPLIT_NO_EMPTY);
    $fields_class = array_key_exists('cssClass', $field) ? $field['cssClass'] : '';
    $field_classes = preg_split('/[\\n\\r\\t ]+/', $fields_class, -1, PREG_SPLIT_NO_EMPTY);
    if (!is_admin()) {
        // multi-column form functionality
        if ($field['type'] == 'section') {
            $form = RGFormsModel::get_form_meta($form_id, true);
            // check for the presence of multi-column form classes
            $form_class = explode(' ', $form['cssClass']);
            $form_class_matches = array_intersect($form_class, array('two-column', 'three-column'));
            // check for the presence of section break column classes
            $field_class = explode(' ', $field['cssClass']);
            $field_class_matches = array_intersect($field_class, array('gform_column'));
            // if field is a column break in a multi-column form, perform the list split
            if (!empty($form_class_matches) && !empty($field_class_matches)) {
                // make sure to target only multi-column forms
                // retrieve the form's field list classes for consistency
                $form = RGFormsModel::add_default_properties($form);
                $description_class = rgar($form, 'descriptionPlacement') == 'above' ? 'description_above' : 'description_below';
                // close current field's li and ul and begin a new list with the same form field list classes
                return '</li></ul><ul class="gform_fields ' . $form['labelPlacement'] . ' ' . $description_class . ' ' . $field['cssClass'] . '"><li class="gfield gsection empty">';
            }
        }
    }
    return $content;
}
 public function get_field_input($form, $value = '', $entry = null)
 {
     $is_entry_detail = $this->is_entry_detail();
     $is_form_editor = $this->is_form_editor();
     if (is_array($value)) {
         $value = array_values($value);
     }
     $form_id = $form['id'];
     $id = intval($this->id);
     $field_id = $is_entry_detail || $is_form_editor || $form_id == 0 ? "input_{$id}" : 'input_' . $form_id . "_{$id}";
     $form_id = ($is_entry_detail || $is_form_editor) && empty($form_id) ? rgget('id') : $form_id;
     $size = $this->size;
     $disabled_text = $is_form_editor ? "disabled='disabled'" : '';
     $class_suffix = $is_entry_detail ? '_admin' : '';
     $class = $this->emailConfirmEnabled ? '' : $size . $class_suffix;
     //Size only applies when confirmation is disabled
     $form_sub_label_placement = rgar($form, 'subLabelPlacement');
     $field_sub_label_placement = $this->subLabelPlacement;
     $is_sub_label_above = $field_sub_label_placement == 'above' || empty($field_sub_label_placement) && $form_sub_label_placement == 'above';
     $sub_label_class_attribute = $field_sub_label_placement == 'hidden_label' ? "class='hidden_sub_label'" : '';
     $html_input_type = RGFormsModel::is_html5_enabled() ? 'email' : 'text';
     $enter_email_field_input = GFFormsModel::get_input($this, $this->id . '');
     $confirm_field_input = GFFormsModel::get_input($this, $this->id . '.2');
     $enter_email_label = rgar($enter_email_field_input, 'customLabel') != '' ? $enter_email_field_input['customLabel'] : __('Enter Email', 'gravityforms');
     $enter_email_label = apply_filters("gform_email_{$form_id}", apply_filters('gform_email', $enter_email_label, $form_id), $form_id);
     $confirm_email_label = rgar($confirm_field_input, 'customLabel') != '' ? $confirm_field_input['customLabel'] : __('Confirm Email', 'gravityforms');
     $confirm_email_label = apply_filters("gform_email_confirm_{$form_id}", apply_filters('gform_email_confirm', $confirm_email_label, $form_id), $form_id);
     $single_placeholder_attribute = $this->get_field_placeholder_attribute();
     $enter_email_placeholder_attribute = $this->get_input_placeholder_attribute($enter_email_field_input);
     $confirm_email_placeholder_attribute = $this->get_input_placeholder_attribute($confirm_field_input);
     if ($is_form_editor) {
         $single_style = $this->emailConfirmEnabled ? "style='display:none;'" : '';
         $confirm_style = $this->emailConfirmEnabled ? '' : "style='display:none;'";
         if ($is_sub_label_above) {
             return "<div class='ginput_container ginput_single_email' {$single_style}>\n                            <input name='input_{$id}' type='{$html_input_type}' class='" . esc_attr($class) . "' disabled='disabled' {$single_placeholder_attribute} />\n                            <div class='gf_clear gf_clear_complex'></div>\n                        </div>\n                        <div class='ginput_complex ginput_container ginput_confirm_email' {$confirm_style} id='{$field_id}_container'>\n                            <span id='{$field_id}_container' class='ginput_left'>\n                                <label for='{$field_id}' {$sub_label_class_attribute}>{$enter_email_label}</label>\n                                <input class='{$class}' type='text' name='input_{$id}' id='{$field_id}' disabled='disabled' {$enter_email_placeholder_attribute}/>\n                            </span>\n                            <span id='{$field_id}_2_container' class='ginput_right'>\n                                <label for='{$field_id}_2' {$sub_label_class_attribute}>{$confirm_email_label}</label>\n                                <input class='{$class}' type='text' name='input_{$id}_2' id='{$field_id}_2' disabled='disabled' {$confirm_email_placeholder_attribute}/>\n                            </span>\n                            <div class='gf_clear gf_clear_complex'></div>\n                        </div>";
         } else {
             return "<div class='ginput_container ginput_single_email' {$single_style}>\n                            <input class='{$class}' name='input_{$id}' type='{$html_input_type}' class='" . esc_attr($class) . "' disabled='disabled' {$single_placeholder_attribute}/>\n                            <div class='gf_clear gf_clear_complex'></div>\n                        </div>\n                        <div class='ginput_complex ginput_container ginput_confirm_email' {$confirm_style} id='{$field_id}_container'>\n                            <span id='{$field_id}_container' class='ginput_left'>\n                                <input class='{$class}' type='text' name='input_{$id}' id='{$field_id}' disabled='disabled' {$enter_email_placeholder_attribute}/>\n                                <label for='{$field_id}' {$sub_label_class_attribute}>{$enter_email_label}</label>\n                            </span>\n                            <span id='{$field_id}_2_container' class='ginput_right'>\n                                <input class='{$class}' type='text' name='input_{$id}_2' id='{$field_id}_2' disabled='disabled' {$confirm_email_placeholder_attribute}/>\n                                <label for='{$field_id}_2' {$sub_label_class_attribute}>{$confirm_email_label}</label>\n                            </span>\n                            <div class='gf_clear gf_clear_complex'></div>\n                        </div>";
         }
     } else {
         $logic_event = $this->get_conditional_logic_event('keyup');
         if ($this->emailConfirmEnabled && !$is_entry_detail) {
             $first_tabindex = $this->get_tabindex();
             $last_tabindex = $this->get_tabindex();
             $email_value = is_array($value) ? esc_attr($value[0]) : $value;
             $confirmation_value = is_array($value) ? esc_attr($value[1]) : rgpost('input_' . $this->id . '_2');
             $confirmation_disabled = $is_entry_detail ? "disabled='disabled'" : $disabled_text;
             if ($is_sub_label_above) {
                 return "<div class='ginput_complex ginput_container' id='{$field_id}_container'>\n                                <span id='{$field_id}_container' class='ginput_left'>\n                                    <label for='{$field_id}'>" . $enter_email_label . "</label>\n                                    <input class='{$class}' type='{$html_input_type}' name='input_{$id}' id='{$field_id}' value='" . $email_value . "' {$first_tabindex} {$logic_event} {$disabled_text} {$enter_email_placeholder_attribute}/>\n                                </span>\n                                <span id='{$field_id}_2_container' class='ginput_right'>\n                                    <label for='{$field_id}_2' {$sub_label_class_attribute}>{$confirm_email_label}</label>\n                                    <input class='{$class}' type='{$html_input_type}' name='input_{$id}_2' id='{$field_id}_2' value='" . $confirmation_value . "' {$last_tabindex} {$confirmation_disabled} {$confirm_email_placeholder_attribute}/>\n                                </span>\n                                <div class='gf_clear gf_clear_complex'></div>\n                            </div>";
             } else {
                 return "<div class='ginput_complex ginput_container' id='{$field_id}_container'>\n                                <span id='{$field_id}_container' class='ginput_left'>\n                                    <input class='{$class}' type='{$html_input_type}' name='input_{$id}' id='{$field_id}' value='" . $email_value . "' {$first_tabindex} {$logic_event} {$disabled_text} {$enter_email_placeholder_attribute}/>\n                                    <label for='{$field_id}' {$sub_label_class_attribute}>{$enter_email_label}</label>\n                                </span>\n                                <span id='{$field_id}_2_container' class='ginput_right'>\n                                    <input class='{$class}' type='{$html_input_type}' name='input_{$id}_2' id='{$field_id}_2' value='" . $confirmation_value . "' {$last_tabindex} {$confirmation_disabled} {$confirm_email_placeholder_attribute}/>\n                                    <label for='{$field_id}_2' {$sub_label_class_attribute}>{$confirm_email_label}</label>\n                                </span>\n                                <div class='gf_clear gf_clear_complex'></div>\n                            </div>";
             }
         } else {
             $tabindex = $this->get_tabindex();
             $value = esc_attr($value);
             $class = esc_attr($class);
             return "<div class='ginput_container'>\n                            <input name='input_{$id}' id='{$field_id}' type='{$html_input_type}' value='{$value}' class='{$class}' {$tabindex} {$logic_event} {$disabled_text} {$single_placeholder_attribute}/>\n                        </div>";
         }
     }
 }
Пример #14
0
 public function tearDown()
 {
     parent::tearDown();
     /*
      * Uninstall Gravity Forms
      */
     RGFormsModel::drop_tables();
 }
Пример #15
0
function get_makerfaire_status_counts($form_id)
{
    global $wpdb;
    $lead_details_table_name = RGFormsModel::get_lead_details_table_name();
    $sql = $wpdb->prepare("SELECT count(0) as entries,value as label FROM {$lead_details_table_name}\n\t\t\t      join wp_rg_lead lead \n                                    on  lead.id = {$lead_details_table_name}.lead_id and \n                                        lead.status = 'active'\n                        where field_number='303'\n\t\t\tand {$lead_details_table_name}.form_id=%d\n\t\t\tgroup by value", $form_id);
    $results = $wpdb->get_results($sql, ARRAY_A);
    return $results;
}
    /**
     * render_field()
     *
     * Create the HTML interface for your field
     *
     * @param $field (array) the $field being rendered
     *
     * @type  action
     * @since 3.6
     * @date  23/01/13
     *
     * @param  $field (array) the $field being edited
     * @return n/a
     */
    function render_field($field)
    {
        $field = array_merge($this->defaults, $field);
        $choices = array();
        if (class_exists('RGFormsModel')) {
            $forms = RGFormsModel::get_forms(1);
        } else {
            echo '<font style="color:red; font-weight:bold;">Warning: Gravity Forms is not installed or activated. This field does not function without Gravity Forms!</font>';
        }
        if (isset($forms)) {
            foreach ($forms as $form) {
                $choices[intval($form->id)] = ucfirst($form->title);
            }
        }
        $field['choices'] = $choices;
        $field['type'] = 'select';
        $multiple = '';
        if ($field['allow_multiple']) {
            $multiple = 'multiple="multiple" data-multiple="1"';
            echo '<input type="hidden" name="' . $field['name'] . '">';
        }
        ?>
        <select id="<?php 
        echo str_replace(array('[', ']'), array('-', ''), $field['name']);
        ?>
" name="<?php 
        echo $field['name'] . ($field['allow_multiple'] ? '[]' : '');
        ?>
" <?php 
        echo $multiple;
        ?>
>
            <?php 
        if ($field['allow_null']) {
            ?>
            <option value="">Select ...</option>
            <?php 
        }
        ?>
            <?php 
        foreach ($field['choices'] as $key => $value) {
            ?>
            <option value="<?php 
            echo $key;
            ?>
" <?php 
            echo (is_array($field['value']) && in_array($key, $field['value']) or $field['value'] == $key) ? 'selected="selected"' : '';
            ?>
><?php 
            echo $value;
            ?>
</option>
            <?php 
        }
        ?>
        </select>
<?php 
    }
function gfuea_clean_zips($confirmation, $form, $entry, $ajax)
{
    $upload_root = RGFormsModel::get_upload_root();
    $filename = $upload_root . "/uploaded_files" . $entry['id'] . ".zip";
    if (is_file($filename)) {
        unlink($filename);
    }
    return $confirmation;
}
 function _get_form_strings($form_id)
 {
     $form = RGFormsModel::get_form_meta($form_id, true);
     $form = RGFormsModel::add_default_properties($form);
     $string_data = array();
     $form_keys = array('title', 'description', 'limitEntriesMessage', 'scheduleMessage', 'postTitleTemplate', 'postContentTemplate', 'confirmation-message', 'autoResponder-subject', 'autoResponder-message', 'button-text');
     foreach ($form_keys as $key) {
         $parts = explode('-', $key);
         if (sizeof($parts) == 1) {
             if (isset($form[$key]) && $form[$key] != '') {
                 $string_data[$key] = $form[$key];
             }
         } else {
             if (isset($form[$parts[0]][$parts[1]]) && $form[$parts[0]][$parts[1]] != '') {
                 $string_data[$key] = $form[$parts[0]][$parts[1]];
             }
         }
     }
     ///- Paging Page Names           - $form["pagination"]["pages"][i]
     $keys = array('label', 'description', 'defaultValue', 'errorMessage');
     foreach ($form['fields'] as $id => $field) {
         foreach ($keys as $key) {
             if (isset($field[$key]) && $field[$key] != '') {
                 $string_data['field-' . $field['id'] . '-' . $key] = $field[$key];
             }
         }
         switch ($field['type']) {
             case 'text':
             case 'textarea':
             case 'email':
             case 'number':
             case 'section':
                 break;
             case 'html':
                 $string_data['field-' . $field['id'] . '-content'] = $field['content'];
                 break;
             case 'page':
                 $string_data['field-' . $field['id'] . '-nextButton'] = $field['nextButton']['text'];
                 $string_data['field-' . $field['id'] . '-previousButton'] = $field['previousButton']['text'];
                 break;
             case 'select':
             case 'checkbox':
             case 'radio':
             case 'product':
                 if (isset($field['choices']) && is_array($field['choices'])) {
                     foreach ($field['choices'] as $index => $choice) {
                         $string_data['field-' . $field['id'] . '-choice-' . $choice['value']] = $choice['text'];
                     }
                 }
                 break;
             case 'post_custom_field':
                 $string_data['field-' . $field['id'] . '-customFieldTemplate'] = $field["customFieldTemplate"];
                 break;
         }
     }
     return $string_data;
 }
Пример #19
0
 function get_forms()
 {
     $forms = RGFormsModel::get_forms();
     $options = array('' => '&ndash; Select a Form &ndash;');
     foreach ($forms as $form) {
         $options[$form->id] = $form->title;
     }
     return $options;
 }
Пример #20
0
 public function get_field_input($form, $value = '', $entry = null)
 {
     $is_entry_detail = $this->is_entry_detail();
     $is_form_editor = $this->is_form_editor();
     $form_id = $form['id'];
     $id = intval($this->id);
     $field_id = $is_entry_detail || $is_form_editor || $form_id == 0 ? "input_{$id}" : 'input_' . $form_id . "_{$id}";
     $form_sub_label_placement = rgar($form, 'subLabelPlacement');
     $field_sub_label_placement = rgar($this, 'subLabelPlacement');
     $is_sub_label_above = $field_sub_label_placement == 'above' || empty($field_sub_label_placement) && $form_sub_label_placement == 'above';
     $sub_label_class_attribute = $field_sub_label_placement == 'hidden_label' ? "class='hidden_sub_label'" : '';
     $disabled_text = $is_form_editor ? "disabled='disabled'" : '';
     $hour = $minute = $am_selected = $pm_selected = '';
     if (!is_array($value) && !empty($value)) {
         preg_match('/^(\\d*):(\\d*) ?(.*)$/', $value, $matches);
         $hour = esc_attr($matches[1]);
         $minute = esc_attr($matches[2]);
         $the_rest = strtolower(rgar($matches, 3));
         $am_selected = strpos($the_rest, 'am') > -1 ? "selected='selected'" : '';
         $pm_selected = strpos($the_rest, 'pm') > -1 ? "selected='selected'" : '';
     } else {
         if (is_array($value)) {
             $value = array_values($value);
             $hour = esc_attr($value[0]);
             $minute = esc_attr($value[1]);
             $am_selected = strtolower(rgar($value, 2)) == 'am' ? "selected='selected'" : '';
             $pm_selected = strtolower(rgar($value, 2)) == 'pm' ? "selected='selected'" : '';
         }
     }
     $hour_input = GFFormsModel::get_input($this, $this->id . '.1');
     $minute_input = GFFormsModel::get_input($this, $this->id . '.2');
     $hour_placeholder_attribute = $this->get_input_placeholder_attribute($hour_input);
     $minute_placeholder_attribute = $this->get_input_placeholder_attribute($minute_input);
     $hour_tabindex = $this->get_tabindex();
     $minute_tabindex = $this->get_tabindex();
     $ampm_tabindex = $this->get_tabindex();
     $is_html5 = RGFormsModel::is_html5_enabled();
     $input_type = $is_html5 ? 'number' : 'text';
     $max_hour = $this->timeFormat == '24' ? 23 : 12;
     $hour_html5_attributes = $is_html5 ? "min='0' max='{$max_hour}' step='1'" : '';
     $minute_html5_attributes = $is_html5 ? "min='0' max='59' step='1'" : '';
     $ampm_field_style = $is_form_editor && $this->timeFormat == '24' ? "style='display:none;'" : '';
     if ($is_form_editor || $this->timeFormat != '24') {
         $am_text = __('AM', 'gravityforms');
         $pm_text = __('PM', 'gravityforms');
         $ampm_field = $is_sub_label_above ? "<div class='gfield_time_ampm ginput_container' {$ampm_field_style}>\n                                                            <label for='{$field_id}_3'>&nbsp;</label>\n                                                            <select name='input_{$id}[]' id='{$field_id}_3' {$ampm_tabindex} {$disabled_text}>\n                                                                <option value='am' {$am_selected}>{$am_text}</option>\n                                                                <option value='pm' {$pm_selected}>{$pm_text}</option>\n                                                            </select>\n                                                          </div>" : "<div class='gfield_time_ampm ginput_container' {$ampm_field_style}>\n                                                            <select name='input_{$id}[]' id='{$field_id}_3' {$ampm_tabindex} {$disabled_text}>\n                                                                <option value='am' {$am_selected}>{$am_text}</option>\n                                                                <option value='pm' {$pm_selected}>{$pm_text}</option>\n                                                            </select>\n                                                          </div>";
     } else {
         $ampm_field = '';
     }
     $hour_label = rgar($hour_input, 'customLabel') != '' ? $hour_input['customLabel'] : __('HH', 'gravityforms');
     $minute_label = rgar($minute_input, 'customLabel') != '' ? $minute_input['customLabel'] : _x('MM', 'Abbreviation: Minutes', 'gravityforms');
     if ($is_sub_label_above) {
         return "<div class='clear-multi'>\n                        <div class='gfield_time_hour ginput_container' id='{$field_id}'>\n                            <label for='{$field_id}_1' {$sub_label_class_attribute}>{$hour_label}</label>\n                            <input type='{$input_type}' maxlength='2' name='input_{$id}[]' id='{$field_id}_1' value='{$hour}' {$hour_tabindex} {$hour_html5_attributes} {$disabled_text} {$hour_placeholder_attribute}/> <i>:</i>\n                        </div>\n                        <div class='gfield_time_minute ginput_container'>\n                            <label for='{$field_id}_2' {$sub_label_class_attribute}>{$minute_label}</label>\n                            <input type='{$input_type}' maxlength='2' name='input_{$id}[]' id='{$field_id}_2' value='{$minute}' {$minute_tabindex} {$minute_html5_attributes} {$disabled_text} {$minute_placeholder_attribute}/>\n                        </div>\n                        {$ampm_field}\n                    </div>";
     } else {
         return "<div class='clear-multi'>\n                        <div class='gfield_time_hour ginput_container' id='{$field_id}'>\n                            <input type='{$input_type}' maxlength='2' name='input_{$id}[]' id='{$field_id}_1' value='{$hour}' {$hour_tabindex} {$hour_html5_attributes} {$disabled_text} {$hour_placeholder_attribute}/> <i>:</i>\n                            <label for='{$field_id}_1' {$sub_label_class_attribute}>{$hour_label}</label>\n                        </div>\n                        <div class='gfield_time_minute ginput_container'>\n                            <input type='{$input_type}' maxlength='2' name='input_{$id}[]' id='{$field_id}_2' value='{$minute}' {$minute_tabindex} {$minute_html5_attributes} {$disabled_text} {$minute_placeholder_attribute}/>\n                            <label for='{$field_id}_2' {$sub_label_class_attribute}>{$minute_label}</label>\n                        </div>\n                        {$ampm_field}\n                    </div>";
     }
 }
 public function get_gravity_forms()
 {
     $forms = RGFormsModel::get_forms(null, 'title');
     $form_array = array();
     foreach ($forms as $form) {
         $form_array[$form->id] = $form->title;
     }
     return $form_array;
 }
Пример #22
0
function lpop_gform_get_entry($attrs)
{
    /* Parse the id */
    $entry = RGFormsModel::get_lead(1);
    $form = GFFormsModel::get_form_meta($entry['form_id']);
    LPOP_Logger::logit("Loading Mini Audits: Form =  " . $form['title'] . ", Entry = " . $entry['id']);
    LPOP_Mini_Audits::process_mini_audit_entry($entry);
    LPOP_Logger::flush();
}
Пример #23
0
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;
}
function gforms_autologin($user_id, $config, $entry, $password)
{
    $form = RGFormsModel::get_form_meta($entry['form_id']);
    $user_login = apply_filters("gform_username_{$form['id']}", apply_filters('gform_username', GFUser::get_meta_value('username', $config, $form, $entry), $config, $form, $entry), $config, $form, $entry);
    $redirect_url = rgars($form, 'confirmation/url') ? rgars($form, 'confirmation/url') : get_bloginfo('home');
    //pass the above to the wp_signon function
    $result = wp_signon(array('user_login' => $user_login, 'user_password' => $password, 'remember' => false));
    if (!is_wp_error($result)) {
        wp_redirect($redirect_url);
    }
}
 /**
  * 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;
 }
Пример #26
0
 /**
  * Get all forms and return in a simple array for output.
  *
  * @since WP Job Manager - Contact Listing 1.0.0
  *
  * @return void
  */
 public function get_forms()
 {
     $forms = array(0 => __('Please select a form', 'wp-job-manager-contact-listing'));
     $_forms = RGFormsModel::get_forms(null, 'title');
     if (!empty($_forms)) {
         foreach ($_forms as $_form) {
             $forms[$_form->id] = $_form->title;
         }
     }
     return $forms;
 }
Пример #27
0
 public function migrate()
 {
     global $wpdb;
     $form_ids = $wpdb->get_col("SELECT id FROM {$wpdb->prefix}rg_form");
     foreach ($form_ids as $id) {
         $form = RGFormsModel::get_form_meta($id, true);
         $this->tm_api->update_form_translations($form, true);
         $wpdb->delete($wpdb->prefix . 'icl_translations', array('element_id' => $id, 'element_type' => 'post_gravity_form'));
         $this->migrate_old_translated_values($id);
     }
 }
 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;
 }
Пример #29
0
 public static function get_feeds()
 {
     global $wpdb;
     $table_name = self::get_freshbooks_table_name();
     $form_table_name = RGFormsModel::get_form_table_name();
     $sql = "SELECT s.id, s.is_active, s.form_id, s.meta, f.title as form_title\r\n                FROM {$table_name} s\r\n                INNER JOIN {$form_table_name} f ON s.form_id = f.id";
     $results = $wpdb->get_results($sql, ARRAY_A);
     $count = sizeof($results);
     for ($i = 0; $i < $count; $i++) {
         $results[$i]["meta"] = maybe_unserialize($results[$i]["meta"]);
     }
     return $results;
 }
Пример #30
0
/**
 * Outputs the GFORMS options metabox in action box edit screen
 * @param  object $post the current post
 * @return html
 */
function mab_gforms_meta_box($post)
{
    $MabBase = MAB();
    $data['meta'] = $MabBase->get_mab_meta($post->ID);
    $type = $MabBase->get_action_box_type($post->ID);
    //Get gravity forms stuff
    $forms = RGFormsModel::get_forms(null, 'title');
    $data['forms'] = is_array($forms) ? $forms : array();
    //error_log();
    $filename = 'metabox/metabox.php';
    $box = mab_gforms_get_view($filename, $data);
    echo $box;
}