示例#1
1
 /**
  * Fetch Field Label
  *
  * @access public
  * @static
  * @param array $field GravityView field array
  * @param array $entry Gravity Forms entry array
  * @param boolean $force_show_label Whether to always show the label, regardless of field settings
  * @return string
  */
 public static function field_label($field, $entry = array(), $force_show_label = false)
 {
     $gravityview_view = GravityView_View::getInstance();
     $form = $gravityview_view->getForm();
     $label = '';
     if (!empty($field['show_label']) || $force_show_label) {
         $label = $field['label'];
         // Support Gravity Forms 1.9+
         if (class_exists('GF_Field')) {
             $field_object = RGFormsModel::get_field($form, $field['id']);
             if ($field_object) {
                 $input = GFFormsModel::get_input($field_object, $field['id']);
                 // This is a complex field, with lables on a per-input basis
                 if ($input) {
                     // Does the input have a custom label on a per-input basis? Otherwise, default label.
                     $label = !empty($input['customLabel']) ? $input['customLabel'] : $input['label'];
                 } else {
                     // This is a field with one label
                     $label = $field_object->get_field_label(true, $field['label']);
                 }
             }
         }
         // Use Gravity Forms label by default, but if a custom label is defined in GV, use it.
         if (!empty($field['custom_label'])) {
             $label = self::replace_variables($field['custom_label'], $form, $entry);
         }
         $label .= apply_filters('gravityview_render_after_label', '', $field);
     }
     // End $field['show_label']
     /**
      * @since 1.7
      */
     $label = apply_filters('gravityview/template/field_label', $label, $field, $form, $entry);
     return $label;
 }
示例#2
1
 public function run($arguments)
 {
     if (class_exists('RGFormsModel') && is_callable(array('RGFormsModel', 'get_form_meta')) && class_exists('GFAPI') && is_callable(array('GFAPI', 'get_entries'))) {
         if (empty($arguments['id'])) {
             return array('error' => 'Form ID Required');
         }
         $return = array();
         $form_meta = GFFormsModel::get_form_meta(absint($arguments['id']));
         $return['field_labels'] = array();
         foreach ($form_meta['fields'] as $field) {
             $return['field_labels']["{$field['id']}"] = $this->_process_label($field);
         }
         $return['current_page'] = empty($arguments['page']) ? 1 : absint($arguments['page']);
         if ($return['current_page'] < 1) {
             $return['current_page'] = 1;
         }
         $paging = array('page_size' => 20);
         $paging['offset'] = ($return['current_page'] - 1) * $paging['page_size'];
         $return['total_count'] = 0;
         $return['entries'] = GFAPI::get_entries(absint($arguments['id']), null, null, $paging, $return['total_count']);
         $return['page_size'] = $paging['page_size'];
         $return['total_pages'] = ceil($return['total_count'] / $paging['page_size']);
         return $return;
     }
     return false;
 }
 function widget($args, $instance)
 {
     $gf_polls = GFPolls::get_instance();
     wp_enqueue_script('gpoll_js', plugins_url('js/gpoll.js', __FILE__), array('jquery'), $gf_polls->_version);
     $gf_polls->localize_scripts();
     wp_enqueue_style('gpoll_css', plugins_url('css/gpoll.css', __FILE__), null, $gf_polls->_version);
     extract($args);
     echo $before_widget;
     $title = apply_filters('widget_title', $instance['title']);
     $form_id = $instance['form_id'];
     if ($title) {
         echo $before_title . $title . $after_title;
     }
     $mode = rgar($instance, "mode");
     $override_form_settings = rgar($instance, 'override_form_settings');
     if ("" === $override_form_settings) {
         $override_form_settings = true;
     }
     if ($override_form_settings) {
         $style = rgar($instance, "style");
         $display_results = rgar($instance, "display_results");
         $display_results_string = $display_results == "1" ? "true" : "false";
         $show_results_link = rgar($instance, "show_results_link");
         $show_results_link_string = $show_results_link == "1" ? "true" : "false";
         $show_percentages = rgar($instance, "show_percentages");
         $show_percentages_string = $show_percentages == "1" ? "true" : "false";
         $show_counts = rgar($instance, "show_counts");
         $show_counts_string = $show_counts == "1" ? "true" : "false";
         $block_repeat_voters = rgar($instance, "block_repeat_voters");
         $cookie = $block_repeat_voters == "1" ? rgar($instance, "cookie") : "";
         $displayconfirmation = rgar($instance, "displayconfirmation");
         $displayconfirmation = $displayconfirmation == "1" ? "true" : "false";
     } else {
         $form = GFFormsModel::get_form_meta($form_id);
         $style = $gf_polls->get_form_setting($form, "style");
         $display_results = $gf_polls->get_form_setting($form, "displayResults");
         $display_results_string = $display_results ? "true" : "false";
         $show_results_link = $gf_polls->get_form_setting($form, "showResultsLink");
         $show_results_link_string = $show_results_link ? "true" : "false";
         $show_percentages = $gf_polls->get_form_setting($form, "showPercentages");
         $show_percentages_string = $show_percentages ? "true" : "false";
         $show_counts = $gf_polls->get_form_setting($form, "showCounts");
         $show_counts_string = $show_counts ? "true" : "false";
         $block_repeat_voters = $gf_polls->get_form_setting($form, "blockRepeatVoters");
         $cookie = $block_repeat_voters ? $gf_polls->get_form_setting($form, "cookie") : "";
         $displayconfirmation = "true";
     }
     $tabindex = rgar($instance, "tabindex");
     $showtitle = rgar($instance, "showtitle");
     $showtitle = $showtitle == "1" ? "true" : "false";
     $showdescription = rgar($instance, "showdescription");
     $showdescription = $showdescription == "1" ? "true" : "false";
     $ajax = rgar($instance, "ajax");
     $ajax = $ajax == "1" ? "true" : "false";
     $disable_scripts = rgar($instance, "disable_scripts");
     $disable_scripts = $disable_scripts == "1" ? "true" : "false";
     $shortcode = "[gravityforms action=\"polls\" field=\"0\" id=\"{$form_id}\" style=\"{$style}\" mode=\"{$mode}\" display_results=\"{$display_results_string}\" show_results_link=\"{$show_results_link_string}\" cookie=\"{$cookie}\" ajax=\"{$ajax}\" disable_scripts=\"{$disable_scripts}\" tabindex=\"{$tabindex}\" title=\"{$showtitle}\" description=\"{$showdescription}\" confirmation=\"{$displayconfirmation}\" percentages=\"{$show_percentages_string}\" counts=\"{$show_counts_string}\"]";
     echo do_shortcode($shortcode);
     echo $after_widget;
 }
 public function get_value_submission($field_values, $get_from_post_global_var = true)
 {
     $parameter_values = GFFormsModel::get_parameter_value($this->inputName, $field_values, $this);
     if (!empty($parameter_values) && !is_array($parameter_values)) {
         $parameter_values = explode(',', $parameter_values);
     }
     if (!is_array($this->inputs)) {
         return '';
     }
     $choice_index = 0;
     $value = array();
     foreach ($this->inputs as $input) {
         if (!empty($_POST['is_submit_' . $this->formId]) && $get_from_post_global_var) {
             $input_value = rgpost('input_' . str_replace('.', '_', strval($input['id'])));
             if (is_array($input_value)) {
                 $input_value = '';
             }
             $value[strval($input['id'])] = $input_value;
         } else {
             if (is_array($parameter_values)) {
                 foreach ($parameter_values as $item) {
                     $item = trim($item);
                     if (GFFormsModel::choice_value_match($this, $this->choices[$choice_index], $item)) {
                         $value[$input['id'] . ''] = $item;
                         break;
                     }
                 }
             }
         }
         $choice_index++;
     }
     return $value;
 }
示例#5
0
 /**
  * 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;
 }
 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>";
         }
     }
 }
 /**
  * Update entry property
  *
  * @param int    $entry_id Entry ID
  * @param string $property Name of the property to update
  * @param string $value    Value for the property
  */
 public static function update_entry_property($entry_id, $property, $value)
 {
     if (Pronamic_WP_Pay_Class::method_exists('GFAPI', 'update_entry_property')) {
         GFAPI::update_entry_property($entry_id, $property, $value);
     } elseif (Pronamic_WP_Pay_Class::method_exists('GFFormsModel', 'update_lead_property')) {
         GFFormsModel::update_lead_property($entry_id, $property, $value);
     }
 }
示例#8
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();
}
 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 upload_field_upload_markup($markup, $file, $form_id, $id)
 {
     $file_path = GFFormsModel::get_file_upload_path($form_id, $file['uploaded_filename']);
     $url = explode('/', $file_path['url']);
     array_pop($url);
     array_push($url, $file['uploaded_filename']);
     $file['url'] = implode('/', $url);
     return get_component('twig', 'uploaded-file', compact('file', 'form_id', 'id'), false);
 }
示例#11
0
 /**
  * Delete all GravityView-generated entry notes
  * @since 1.15
  * @return void
  */
 private function delete_entry_notes()
 {
     global $wpdb;
     $notes_table = class_exists('GFFormsModel') ? GFFormsModel::get_lead_notes_table_name() : $wpdb->prefix . 'rg_lead_notes';
     $disapproved = __('Disapproved the Entry for GravityView', 'gravityview');
     $approved = __('Approved the Entry for GravityView', 'gravityview');
     $sql = $wpdb->prepare("\n\t\t\tDELETE FROM {$notes_table}\n            WHERE (\n                `note_type` = 'gravityview' OR\n\t\t\t\t`value` = %s OR\n\t\t\t\t`value` = %s\n            );\n        ", $approved, $disapproved);
     $wpdb->query($sql);
 }
 function check_force($id)
 {
     if (get_option('gform_force_ssl_all') == '1') {
         return true;
     }
     $form_meta = GFFormsModel::get_form_meta_by_id($id);
     if (!empty($form_meta[0]['force_ssl'])) {
         return $form_meta[0]['force_ssl'];
     }
     return false;
 }
 /**
  * Alias for GFFormsModel::get_lead_notes()
  *
  * @see GFFormsModel::get_lead_notes
  * @param int $entry_id Entry to get notes for
  *
  * @return stdClass[] Integer-keyed array of note objects
  */
 public static function get_notes($entry_id)
 {
     $notes = GFFormsModel::get_lead_notes($entry_id);
     /**
      * @filter `gravityview/entry_notes/get_notes` Modify the notes array for an entry
      * @since 1.15
      * @param stdClass[] $notes Integer-keyed array of note objects
      * @param int $entry_id Entry to get notes for
      */
     $notes = apply_filters('gravityview/entry_notes/get_notes', $notes, $entry_id);
     return $notes;
 }
 /**
  * Use the GV Admin Field label for the Password field instead of the per-input setting
  *
  * @since 1.17
  *
  * @param string $label Field label HTML
  * @param array $field GravityView field array
  * @param array $form Gravity Forms form array
  * @param array $entry Gravity Forms entry array
  *
  * @return string If a custom field label isn't set, return the field label for the password field
  */
 function field_label($label = '', $field = array(), $form = array(), $entry = array())
 {
     // If using a custom label, no need to fetch the parent label
     if (!is_numeric($field['id']) || !empty($field['custom_label'])) {
         return $label;
     }
     $field_object = GFFormsModel::get_field($form, $field['id']);
     if ($field_object && 'password' === $field_object->type) {
         $label = $field['label'];
     }
     return $label;
 }
function bb_merge_users_process($from_user, $to_user, $return = false)
{
    global $wpdb;
    // GF doesn't hook into delete_user so we need to change leads manually
    $wpdb->query('UPDATE ' . GFFormsModel::get_lead_table_name() . ' SET created_by = ' . $to_user . ' WHERE created_by = ' . $from_user);
    // But WP handles the rest of it for us :-)
    wp_delete_user($from_user, $to_user);
    if ($return) {
        return true;
    }
    echo '<div class="updated"><p>Merge Complete</p></div>' . "\n";
}
 /**
  * @covers GravityView_API::field_class()
  */
 public function test_field_class()
 {
     $entry = $this->entry;
     $form = $this->form;
     $field_id = 2;
     $field = GFFormsModel::get_field($form, $field_id);
     $this->assertEquals('gv-field-' . $form['id'] . '-' . $field_id, GravityView_API::field_class($field, $form, $entry));
     $field['custom_class'] = 'custom-class-{entry_id}';
     // Test the replace_variables functionality
     $this->assertEquals('custom-class-' . $entry['id'] . ' gv-field-' . $form['id'] . '-' . $field_id, GravityView_API::field_class($field, $form, $entry));
     $field['custom_class'] = 'testing,!@@($)*$ 12383';
     // Test the replace_variables functionality
     $this->assertEquals('testing 12383 gv-field-' . $form['id'] . '-' . $field_id, GravityView_API::field_class($field, $form, $entry));
 }
示例#17
0
 public function __construct(Ure_Lib $lib)
 {
     global $wpdb;
     $this->lib = $lib;
     $this->user_meta_key = $wpdb->prefix . 'ure_allow_gravity_forms';
     $this->form_table_name = GFFormsModel::get_form_table_name();
     $this->form_from_key = "FROM {$this->form_table_name}";
     // GF, v. 1.8.5: forms_model.php, line 223, function get_form_count()
     $this->count_forms_query = "\n            SELECT\n            (SELECT count(0) FROM {$this->form_table_name} WHERE is_trash = 0) as total,\n            (SELECT count(0) FROM {$this->form_table_name} WHERE is_active=1 AND is_trash = 0 ) as active,\n            (SELECT count(0) FROM {$this->form_table_name} WHERE is_active=0 AND is_trash = 0 ) as inactive,\n            (SELECT count(0) FROM {$this->form_table_name} WHERE is_trash=1) as trash\n            ";
     add_action('edit_user_profile', array(&$this, 'edit_user_allowed_forms_list'), 10, 2);
     add_action('profile_update', array(&$this, 'save_user_allowed_forms_list'), 10);
     add_action('admin_head', array(&$this, 'prohibited_links_redirect'));
     //add_action( 'admin_enqueue_scripts', array( &$this, 'load_js' ) );
     add_action('admin_init', array(&$this, 'set_final_hooks'));
 }
示例#18
0
 /**
  * Update entry
  *
  * @param array $entry
  */
 public static function update_entry($entry)
 {
     /*
      * GFFormsModel::update_lead() is no longer in use since version 1.8.8! Instead use GFAPI::update_entry().
      *
      * @see https://github.com/gravityforms/gravityforms/blob/1.8.13/forms_model.php#L587-L624
      * @see https://github.com/gravityforms/gravityforms/blob/1.8.13/includes/api.php#L495-L654
      * @see https://github.com/gravityforms/gravityforms/blob/1.8.7.11/forms_model.php#L587-L621
      */
     if (Pronamic_WP_Pay_Class::method_exists('GFAPI', 'update_entry')) {
         GFAPI::update_entry($entry);
     } elseif (Pronamic_WP_Pay_Class::method_exists('GFFormsModel', 'update_lead')) {
         GFFormsModel::update_lead($entry);
     }
 }
示例#19
0
 /**
  * Send the file.
  *
  * @param $form_id
  * @param $file
  */
 private static function deliver($form_id, $file)
 {
     $path = GFFormsModel::get_upload_path($form_id);
     $file_path = trailingslashit($path) . $file;
     if (file_exists($file_path)) {
         $content_type = self::get_content_type($file_path);
         nocache_headers();
         header('Robots: none');
         header('Content-Type: ' . $content_type);
         header('Content-Description: File Transfer');
         header('Content-Disposition: attachment; filename="' . basename($file) . '"');
         header('Content-Transfer-Encoding: binary');
         self::readfile_chunked($file_path);
         die;
     } else {
         self::die_404();
     }
 }
 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;
     $field_id = $is_entry_detail || $is_form_editor || $form_id == 0 ? "input_{$id}" : 'input_' . $form_id . "_{$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 (empty($price)) {
         $price = 0;
     }
     $has_quantity = sizeof(GFCommon::get_product_fields_by_type($form, array('quantity'), $this->id)) > 0;
     if ($has_quantity) {
         $this->disableQuantity = true;
     }
     $currency = $is_entry_detail && !empty($entry) ? $entry['currency'] : '';
     $quantity_field = '';
     $qty_input_type = GFFormsModel::is_html5_enabled() ? 'number' : 'text';
     $qty_min_attr = GFFormsModel::is_html5_enabled() ? "min='0'" : '';
     $product_quantity_sub_label = apply_filters("gform_product_quantity_{$form_id}", apply_filters('gform_product_quantity', __('Quantity:', 'gravityforms'), $form_id), $form_id);
     if ($is_entry_detail || $is_form_editor) {
         $disabled_text = $is_form_editor ? 'disabled="disabled"' : '';
         $style = $this->disableQuantity ? "style='display:none;'" : '';
         $quantity_field = " <span class='ginput_quantity_label' {$style}>{$product_quantity_sub_label}</span> <input type='{$qty_input_type}' name='input_{$id}.3' value='{$quantity}' id='ginput_quantity_{$form_id}_{$this->id}' class='ginput_quantity' size='10' {$disabled_text}/>";
     } else {
         if (!$this->disableQuantity) {
             $tabindex = $this->get_tabindex();
             $quantity_field .= " <span class='ginput_quantity_label'>" . $product_quantity_sub_label . "</span> <input type='{$qty_input_type}' name='input_{$id}.3' value='{$quantity}' id='ginput_quantity_{$form_id}_{$this->id}' class='ginput_quantity' size='10' {$qty_min_attr} {$tabindex}/>";
         } else {
             if (!is_numeric($quantity)) {
                 $quantity = 1;
             }
             if (!$has_quantity) {
                 $quantity_field .= "<input type='hidden' name='input_{$id}.3' value='{$quantity}' class='ginput_quantity_{$form_id}_{$this->id} gform_hidden' />";
             }
         }
     }
     return "<div class='ginput_container'>\n\t\t\t\t\t<input type='hidden' name='input_{$id}.1' value='{$product_name}' class='gform_hidden' />\n\t\t\t\t\t<span class='ginput_product_price_label'>" . apply_filters("gform_product_price_{$form_id}", apply_filters('gform_product_price', __('Price', 'gravityforms'), $form_id), $form_id) . ":</span> <span class='ginput_product_price' id='{$field_id}'>" . esc_html(GFCommon::to_money($price, $currency)) . "</span>\n\t\t\t\t\t<input type='hidden' name='input_{$id}.2' id='ginput_base_price_{$form_id}_{$this->id}' class='gform_hidden' value='" . esc_attr($price) . "'/>\n\t\t\t\t\t{$quantity_field}\n\t\t\t\t</div>";
 }
 public static function build_sql($atts, $lid = false)
 {
     global $wpdb;
     /*
      * Build our database call 
      */
     $sql = 'SELECT id FROM ' . GFFormsModel::get_lead_table_name() . ' WHERE status = "active"';
     if ($lid === false) {
         $sql .= ' AND form_id = ' . $atts['form_id'];
     } else {
         $sql .= ' AND id = ' . (int) $lid;
     }
     if (isset($atts['show']) && $atts['show'] == 'user' || $lid !== false) {
         $user_id = get_current_user_id();
         $sql .= ' AND created_by = ' . $user_id;
     }
     if ($atts['payment'] == 1) {
         $sql .= ' AND (payment_status = "Approved" OR payment_status IS NULL)';
     }
     return $wpdb->get_results($sql);
 }
 /**
  * Send the file.
  *
  * @param $form_id
  * @param $file
  */
 private static function deliver($form_id, $file)
 {
     $path = GFFormsModel::get_upload_path($form_id);
     $file_path = trailingslashit($path) . $file;
     GFCommon::log_debug("delivering file: {$file_path}");
     if (file_exists($file_path)) {
         GFCommon::log_debug("file exists - starting delivery");
         $content_type = self::get_content_type($file_path);
         $content_disposition = rgget('dl') ? 'attachment' : 'inline';
         nocache_headers();
         header('Robots: none');
         header('Content-Type: ' . $content_type);
         header('Content-Description: File Transfer');
         header('Content-Disposition: ' . $content_disposition . '; filename="' . basename($file) . '"');
         header('Content-Transfer-Encoding: binary');
         self::readfile_chunked($file_path);
         die;
     } else {
         GFCommon::log_debug("file does not exist. abort with 404");
         self::die_404();
     }
 }
示例#23
0
 public function upgrade($previous_version)
 {
     if (version_compare($previous_version, '1.0.5') == -1) {
         $forms = GFAPI::get_forms(true);
         foreach ($forms as $form) {
             $entries = GFAPI::get_entries($form['id']);
             $fields = GFAPI::get_fields_by_type($form, 'repeater');
             foreach ($entries as $entry) {
                 foreach ($fields as $field) {
                     if (array_key_exists($field['id'], $entry)) {
                         $dataArray = GFFormsModel::unserialize($entry[$field['id']]);
                         $dataUpdated = false;
                         if (!is_array($dataArray)) {
                             continue;
                         }
                         foreach ($dataArray as $repeaterChildId => $repeaterChild) {
                             foreach ($repeaterChild as $repeatedFieldId => $repeatedField) {
                                 if (!is_array($repeatedField)) {
                                     if ($repeatedField !== '[gfRepeater-section]') {
                                         $dataUpdated = true;
                                         $dataArray[$repeaterChildId][$repeatedFieldId] = array($repeatedField);
                                     }
                                 } elseif (reset($repeatedField) == '[gfRepeater-section]') {
                                     $dataUpdated = true;
                                     $dataArray[$repeaterChildId][$repeatedFieldId] = reset($repeatedField);
                                 }
                             }
                         }
                         if ($dataUpdated) {
                             GFAPI::update_entry_field($entry['id'], $field['id'], maybe_serialize($dataArray));
                         }
                     }
                 }
             }
         }
     }
 }
 public function get_value_entry_list($value, $entry, $field_id, $columns, $form)
 {
     //if this is the main checkbox field (not an input), display a comma separated list of all inputs
     if (absint($field_id) == $field_id) {
         $lead_field_keys = array_keys($entry);
         $items = array();
         foreach ($lead_field_keys as $input_id) {
             if (is_numeric($input_id) && absint($input_id) == $field_id) {
                 $items[] = GFCommon::selection_display(rgar($entry, $input_id), null, $entry['currency'], false);
             }
         }
         $value = GFCommon::implode_non_blank(', ', $items);
         // special case for post category checkbox fields
         if ($this->type == 'post_category') {
             $value = GFCommon::prepare_post_category_value($value, $this, 'entry_list');
         }
     } else {
         $value = '';
         if (GFFormsModel::is_checkbox_checked($field_id, $columns[$field_id]['label'], $entry, $form)) {
             $value = "<i class='fa fa-check gf_valid'></i>";
         }
     }
     return $value;
 }
示例#25
0
 public static function get_default_field_results($form_id, $field, $search_criteria, &$offset, $page_size, &$more_remaining = false)
 {
     $field_results = '';
     $sorting = array('key' => 'date_created', 'direction' => 'DESC');
     $c = 0;
     do {
         $paging = array('offset' => $offset, 'page_size' => $page_size);
         $leads = GFFormsModel::search_leads($form_id, $search_criteria, $sorting, $paging);
         foreach ($leads as $lead) {
             $value = RGFormsModel::get_lead_field_value($lead, $field);
             $content = apply_filters('gform_entries_field_value', $value, $form_id, $field->id, $lead);
             if (is_array($content)) {
                 $content = join(' ', $content);
             }
             if (!empty($content)) {
                 $field_results .= "<li>{$content}</li>";
                 $c++;
             }
         }
         $offset += $page_size;
     } while ($c < $page_size && !empty($leads));
     if (!empty($leads)) {
         $more_remaining = true;
     }
     return $field_results;
 }
 function set_permissions($path)
 {
     GFCommon::log_debug(__METHOD__ . '(): Setting permissions on: ' . $path);
     GFFormsModel::set_permissions($path);
 }
示例#27
0
 public static function resend_notifications()
 {
     check_admin_referer('gf_resend_notifications', 'gf_resend_notifications');
     $form_id = absint(rgpost('formId'));
     $leads = rgpost('leadIds');
     // may be a single ID or an array of IDs
     if (0 == $leads) {
         // get all the lead ids for the current filter / search
         $filter = rgpost('filter');
         $search = rgpost('search');
         $star = $filter == 'star' ? 1 : null;
         $read = $filter == 'unread' ? 0 : null;
         $status = in_array($filter, array('trash', 'spam')) ? $filter : 'active';
         $search_criteria['status'] = $status;
         if ($star) {
             $search_criteria['field_filters'][] = array('key' => 'is_starred', 'value' => (bool) $star);
         }
         if (!is_null($read)) {
             $search_criteria['field_filters'][] = array('key' => 'is_read', 'value' => (bool) $read);
         }
         $search_field_id = rgpost('fieldId');
         if (isset($_POST['fieldId']) && $_POST['fieldId'] !== '') {
             $key = $search_field_id;
             $val = $search;
             $strpos_row_key = strpos($search_field_id, '|');
             if ($strpos_row_key !== false) {
                 //multi-row
                 $key_array = explode('|', $search_field_id);
                 $key = $key_array[0];
                 $val = $key_array[1] . ':' . $val;
             }
             $search_criteria['field_filters'][] = array('key' => $key, 'operator' => rgempty('operator', $_POST) ? 'is' : rgpost('operator'), 'value' => $val);
         }
         $leads = GFFormsModel::search_lead_ids($form_id, $search_criteria);
     } else {
         $leads = !is_array($leads) ? array($leads) : $leads;
     }
     $form = gf_apply_filters('gform_before_resend_notifications', $form_id, RGFormsModel::get_form_meta($form_id), $leads);
     if (empty($leads) || empty($form)) {
         _e('There was an error while resending the notifications.', 'gravityforms');
         die;
     }
     $notifications = json_decode(rgpost('notifications'));
     if (!is_array($notifications)) {
         die(esc_html__('No notifications have been selected. Please select a notification to be sent.', 'gravityforms'));
     }
     if (!rgempty('sendTo', $_POST) && !GFCommon::is_valid_email_list(rgpost('sendTo'))) {
         die(sprintf(esc_html__('The %sSend To%s email address provided is not valid.', 'gravityforms'), '<strong>', '</strong>'));
     }
     foreach ($leads as $lead_id) {
         $lead = RGFormsModel::get_lead($lead_id);
         foreach ($notifications as $notification_id) {
             $notification = $form['notifications'][$notification_id];
             if (!$notification) {
                 continue;
             }
             //overriding To email if one was specified
             if (rgpost('sendTo')) {
                 $notification['to'] = rgpost('sendTo');
                 $notification['toType'] = 'email';
             }
             GFCommon::send_notification($notification, $form, $lead);
         }
     }
     die;
 }
示例#28
0
    public static function lead_detail_page()
    {
        global $current_user;
        if (!GFCommon::ensure_wp_version()) {
            return;
        }
        echo GFCommon::get_remote_message();
        $form = RGFormsModel::get_form_meta(absint($_GET['id']));
        $form_id = absint($form['id']);
        $form = apply_filters('gform_admin_pre_render_' . $form_id, apply_filters('gform_admin_pre_render', $form));
        $lead_id = absint(rgget('lid'));
        $filter = rgget('filter');
        $status = in_array($filter, array('trash', 'spam')) ? $filter : 'active';
        $position = rgget('pos') ? rgget('pos') : 0;
        $sort_direction = rgget('dir') ? rgget('dir') : 'DESC';
        $sort_field = empty($_GET['sort']) ? 0 : $_GET['sort'];
        $sort_field_meta = RGFormsModel::get_field($form, $sort_field);
        $is_numeric = $sort_field_meta['type'] == 'number';
        $star = $filter == 'star' ? 1 : null;
        $read = $filter == 'unread' ? 0 : null;
        $search_criteria['status'] = $status;
        if ($star) {
            $search_criteria['field_filters'][] = array('key' => 'is_starred', 'value' => (bool) $star);
        }
        if (!is_null($read)) {
            $search_criteria['field_filters'][] = array('key' => 'is_read', 'value' => (bool) $read);
        }
        $search_field_id = rgget('field_id');
        if (isset($_GET['field_id']) && $_GET['field_id'] !== '') {
            $key = $search_field_id;
            $val = rgget('s');
            $strpos_row_key = strpos($search_field_id, '|');
            if ($strpos_row_key !== false) {
                //multi-row likert
                $key_array = explode('|', $search_field_id);
                $key = $key_array[0];
                $val = $key_array[1] . ':' . $val;
            }
            $search_criteria['field_filters'][] = array('key' => $key, 'operator' => rgempty('operator', $_GET) ? 'is' : rgget('operator'), 'value' => $val);
            $type = rgget('type');
            if (empty($type)) {
                if (rgget('field_id') == '0') {
                    $search_criteria['type'] = 'global';
                }
            }
        }
        $paging = array('offset' => $position, 'page_size' => 1);
        if (!empty($sort_field)) {
            $sorting = array('key' => $_GET['sort'], 'direction' => $sort_direction, 'is_numeric' => $is_numeric);
        } else {
            $sorting = array();
        }
        $total_count = 0;
        $leads = GFAPI::get_entries($form['id'], $search_criteria, $sorting, $paging, $total_count);
        $prev_pos = !rgblank($position) && $position > 0 ? $position - 1 : false;
        $next_pos = !rgblank($position) && $position < $total_count - 1 ? $position + 1 : false;
        // unread filter requires special handling for pagination since entries are filter out of the query as they are read
        if ($filter == 'unread') {
            $next_pos = $position;
            if ($next_pos + 1 == $total_count) {
                $next_pos = false;
            }
        }
        if (!$lead_id) {
            $lead = !empty($leads) ? $leads[0] : false;
        } else {
            $lead = GFAPI::get_entry($lead_id);
        }
        if (!$lead) {
            esc_html_e("Oops! We couldn't find your entry. Please try again", 'gravityforms');
            return;
        }
        RGFormsModel::update_lead_property($lead['id'], 'is_read', 1);
        switch (RGForms::post('action')) {
            case 'update':
                check_admin_referer('gforms_save_entry', 'gforms_save_entry');
                //Loading files that have been uploaded to temp folder
                $files = GFCommon::json_decode(stripslashes(RGForms::post('gform_uploaded_files')));
                if (!is_array($files)) {
                    $files = array();
                }
                GFFormsModel::$uploaded_files[$form_id] = $files;
                GFFormsModel::save_lead($form, $lead);
                do_action('gform_after_update_entry', $form, $lead['id']);
                do_action("gform_after_update_entry_{$form['id']}", $form, $lead['id']);
                $lead = RGFormsModel::get_lead($lead['id']);
                $lead = GFFormsModel::set_entry_meta($lead, $form);
                break;
            case 'add_note':
                check_admin_referer('gforms_update_note', 'gforms_update_note');
                $user_data = get_userdata($current_user->ID);
                RGFormsModel::add_note($lead['id'], $current_user->ID, $user_data->display_name, stripslashes($_POST['new_note']));
                //emailing notes if configured
                if (rgpost('gentry_email_notes_to')) {
                    GFCommon::log_debug('GFEntryDetail::lead_detail_page(): Preparing to email entry notes.');
                    $email_to = $_POST['gentry_email_notes_to'];
                    $email_from = $current_user->user_email;
                    $email_subject = stripslashes($_POST['gentry_email_subject']);
                    $body = stripslashes($_POST['new_note']);
                    $headers = "From: \"{$email_from}\" <{$email_from}> \r\n";
                    GFCommon::log_debug("GFEntryDetail::lead_detail_page(): Emailing notes - TO: {$email_to} SUBJECT: {$email_subject} BODY: {$body} HEADERS: {$headers}");
                    $is_success = wp_mail($email_to, $email_subject, $body, $headers);
                    $result = is_wp_error($is_success) ? $is_success->get_error_message() : $is_success;
                    GFCommon::log_debug("GFEntryDetail::lead_detail_page(): Result from wp_mail(): {$result}");
                    if (!is_wp_error($is_success) && $is_success) {
                        GFCommon::log_debug('GFEntryDetail::lead_detail_page(): Mail was passed from WordPress to the mail server.');
                    } else {
                        GFCommon::log_error('GFEntryDetail::lead_detail_page(): The mail message was passed off to WordPress for processing, but WordPress was unable to send the message.');
                    }
                    if (has_filter('phpmailer_init')) {
                        GFCommon::log_debug(__METHOD__ . '(): The WordPress phpmailer_init hook has been detected, usually used by SMTP plugins, it can impact mail delivery.');
                    }
                    do_action('gform_post_send_entry_note', $result, $email_to, $email_from, $email_subject, $body, $form, $lead);
                }
                break;
            case 'add_quick_note':
                check_admin_referer('gforms_save_entry', 'gforms_save_entry');
                $user_data = get_userdata($current_user->ID);
                RGFormsModel::add_note($lead['id'], $current_user->ID, $user_data->display_name, stripslashes($_POST['quick_note']));
                break;
            case 'bulk':
                check_admin_referer('gforms_update_note', 'gforms_update_note');
                if ($_POST['bulk_action'] == 'delete') {
                    if (!GFCommon::current_user_can_any('gravityforms_edit_entry_notes')) {
                        die(esc_html__("You don't have adequate permission to delete notes.", 'gravityforms'));
                    }
                    RGFormsModel::delete_notes($_POST['note']);
                }
                break;
            case 'trash':
                check_admin_referer('gforms_save_entry', 'gforms_save_entry');
                RGFormsModel::update_lead_property($lead['id'], 'status', 'trash');
                $lead = RGFormsModel::get_lead($lead['id']);
                break;
            case 'restore':
            case 'unspam':
                check_admin_referer('gforms_save_entry', 'gforms_save_entry');
                RGFormsModel::update_lead_property($lead['id'], 'status', 'active');
                $lead = RGFormsModel::get_lead($lead['id']);
                break;
            case 'spam':
                check_admin_referer('gforms_save_entry', 'gforms_save_entry');
                RGFormsModel::update_lead_property($lead['id'], 'status', 'spam');
                $lead = RGFormsModel::get_lead($lead['id']);
                break;
            case 'delete':
                check_admin_referer('gforms_save_entry', 'gforms_save_entry');
                if (!GFCommon::current_user_can_any('gravityforms_delete_entries')) {
                    die(esc_html__("You don't have adequate permission to delete entries.", 'gravityforms'));
                }
                RGFormsModel::delete_lead($lead['id']);
                ?>
				<script type="text/javascript">
					document.location.href = '<?php 
                echo 'admin.php?page=gf_entries&view=entries&id=' . absint($form['id']);
                ?>
';
				</script>
				<?php 
                break;
        }
        $mode = empty($_POST['screen_mode']) ? 'view' : $_POST['screen_mode'];
        $min = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG || isset($_GET['gform_debug']) ? '' : '.min';
        ?>
		<link rel="stylesheet" href="<?php 
        echo GFCommon::get_base_url();
        ?>
/css/admin<?php 
        echo $min;
        ?>
.css" />
		<script type="text/javascript">

			jQuery(document).ready(function () {
				toggleNotificationOverride(true);
				jQuery('#gform_update_button').prop('disabled', false);
			});

			function DeleteFile(leadId, fieldId, deleteButton) {
				if (confirm(<?php 
        echo json_encode(__("Would you like to delete this file? 'Cancel' to stop. 'OK' to delete", 'gravityforms'));
        ?>
)) {
					var fileIndex = jQuery(deleteButton).parent().index();
					var mysack = new sack("<?php 
        echo admin_url('admin-ajax.php');
        ?>
");
					mysack.execute = 1;
					mysack.method = 'POST';
					mysack.setVar("action", "rg_delete_file");
					mysack.setVar("rg_delete_file", "<?php 
        echo wp_create_nonce('rg_delete_file');
        ?>
");
					mysack.setVar("lead_id", leadId);
					mysack.setVar("field_id", fieldId);
					mysack.setVar("file_index", fileIndex);
					mysack.onError = function () {
						alert(<?php 
        echo json_encode(__('Ajax error while deleting field.', 'gravityforms'));
        ?>
)
					};
					mysack.runAJAX();

					return true;
				}
			}

			function EndDeleteFile(fieldId, fileIndex) {
				var previewFileSelector = "#preview_existing_files_" + fieldId + " .ginput_preview";
				var $previewFiles = jQuery(previewFileSelector);
				var rr = $previewFiles.eq(fileIndex);
				$previewFiles.eq(fileIndex).remove();
				var $visiblePreviewFields = jQuery(previewFileSelector);
				if ($visiblePreviewFields.length == 0) {
					jQuery('#preview_' + fieldId).hide();
					jQuery('#upload_' + fieldId).show('slow');
				}
			}

			function ToggleShowEmptyFields() {
				if (jQuery("#gentry_display_empty_fields").is(":checked")) {
					createCookie("gf_display_empty_fields", true, 10000);
					document.location = document.location.href;
				}
				else {
					eraseCookie("gf_display_empty_fields");
					document.location = document.location.href;
				}
			}

			function createCookie(name, value, days) {
				if (days) {
					var date = new Date();
					date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
					var expires = "; expires=" + date.toGMTString();
				}
				else var expires = "";
				document.cookie = name + "=" + value + expires + "; path=/";
			}

			function eraseCookie(name) {
				createCookie(name, "", -1);
			}

			function ResendNotifications() {

				var selectedNotifications = new Array();
				jQuery(".gform_notifications:checked").each(function () {
					selectedNotifications.push(jQuery(this).val());
				});

				var sendTo = jQuery('#notification_override_email').val();

				if (selectedNotifications.length <= 0) {
					displayMessage(<?php 
        echo json_encode(__('You must select at least one type of notification to resend.', 'gravityforms'));
        ?>
, 'error', '#notifications_container');
					return;
				}

				jQuery('#please_wait_container').fadeIn();

				jQuery.post(ajaxurl, {
						action                 : "gf_resend_notifications",
						gf_resend_notifications: '<?php 
        echo wp_create_nonce('gf_resend_notifications');
        ?>
',
						notifications          : jQuery.toJSON(selectedNotifications),
						sendTo                 : sendTo,
						leadIds                : '<?php 
        echo absint($lead['id']);
        ?>
',
						formId                 : '<?php 
        echo absint($form['id']);
        ?>
'
					},
					function (response) {
						if (response) {
							displayMessage(response, "error", "#notifications_container");
						} else {
							displayMessage(<?php 
        echo json_encode(esc_html__('Notifications were resent successfully.', 'gravityforms'));
        ?>
, "updated", "#notifications_container" );

							// reset UI
							jQuery(".gform_notifications").attr( 'checked', false );
							jQuery('#notification_override_email').val('');

							toggleNotificationOverride();

						}

						jQuery('#please_wait_container').hide();
						setTimeout(function () {
							jQuery('#notifications_container').find('.message').slideUp();
						}, 5000);
					}
				);

			}

			function displayMessage( message, messageClass, container ) {
				jQuery( container ).find( '.message' ).hide().html( message ).attr( 'class', 'message ' + messageClass ).slideDown();
			}

			function toggleNotificationOverride(isInit) {

				if (isInit)
					jQuery('#notification_override_email').val('');

				if (jQuery(".gform_notifications:checked").length > 0) {
					jQuery('#notifications_override_settings').slideDown();
				}
				else {
					jQuery('#notifications_override_settings').slideUp(function () {
						jQuery('#notification_override_email').val('');
					});
				}
			}

		</script>

		<form method="post" id="entry_form" enctype='multipart/form-data'>
		<?php 
        wp_nonce_field('gforms_save_entry', 'gforms_save_entry');
        ?>
		<input type="hidden" name="action" id="action" value="" />
		<input type="hidden" name="screen_mode" id="screen_mode" value="<?php 
        echo esc_attr(rgpost('screen_mode'));
        ?>
" />

		<div class="wrap gf_entry_wrap">
		<h2 class="gf_admin_page_title">
			<span><?php 
        echo esc_html__('Entry #', 'gravityforms') . absint($lead['id']);
        ?>
</span><span class="gf_admin_page_subtitle"><span class="gf_admin_page_formid">ID: <?php 
        echo absint($form['id']);
        ?>
</span><span class='gf_admin_page_formname'><?php 
        esc_html_e('Form Name', 'gravityforms');
        ?>
: <?php 
        echo esc_html($form['title']);
        $gf_entry_locking = new GFEntryLocking();
        $gf_entry_locking->lock_info($lead_id);
        ?>
</span></span></h2>

		<?php 
        if (isset($_GET['pos'])) {
            ?>
			<div class="gf_entry_detail_pagination">
				<ul>
					<li class="gf_entry_count">
						<span>entry <strong><?php 
            echo $position + 1;
            ?>
</strong> of <strong><?php 
            echo $total_count;
            ?>
</strong></span>
					</li>
					<li class="gf_entry_prev gf_entry_pagination"><?php 
            echo GFEntryDetail::entry_detail_pagination_link($prev_pos, 'Previous Entry', 'gf_entry_prev_link', 'fa fa-arrow-circle-o-left');
            ?>
</li>
					<li class="gf_entry_next gf_entry_pagination"><?php 
            echo GFEntryDetail::entry_detail_pagination_link($next_pos, 'Next Entry', 'gf_entry_next_link', 'fa fa-arrow-circle-o-right');
            ?>
</li>
				</ul>
			</div>
		<?php 
        }
        ?>

		<?php 
        RGForms::top_toolbar();
        ?>

		<div id="poststuff" class="metabox-holder has-right-sidebar">
		<div id="side-info-column" class="inner-sidebar">
		<?php 
        do_action('gform_entry_detail_sidebar_before', $form, $lead);
        ?>

		<!-- INFO BOX -->
		<div id="submitdiv" class="stuffbox">
			<h3 class="hndle" style="cursor:default;">
				<span><?php 
        esc_html_e('Entry', 'gravityforms');
        ?>
</span>
			</h3>

			<div class="inside">
				<div id="submitcomment" class="submitbox">
					<div id="minor-publishing" style="padding:10px;">
						<?php 
        esc_html_e('Entry Id', 'gravityforms');
        ?>
: <?php 
        echo absint($lead['id']);
        ?>
<br /><br />
						<?php 
        esc_html_e('Submitted on', 'gravityforms');
        ?>
: <?php 
        echo esc_html(GFCommon::format_date($lead['date_created'], false, 'Y/m/d'));
        ?>
						<br /><br />
						<?php 
        esc_html_e('User IP', 'gravityforms');
        ?>
: <?php 
        echo esc_html($lead['ip']);
        ?>
						<br /><br />
						<?php 
        if (!empty($lead['created_by']) && ($usermeta = get_userdata($lead['created_by']))) {
            ?>
							<?php 
            esc_html_e('User', 'gravityforms');
            ?>
:
							<a href="user-edit.php?user_id=<?php 
            echo absint($lead['created_by']);
            ?>
" alt="<?php 
            esc_attr_e('View user profile', 'gravityforms');
            ?>
" title="<?php 
            esc_attr_e('View user profile', 'gravityforms');
            ?>
"><?php 
            echo esc_html($usermeta->user_login);
            ?>
</a>
							<br /><br />
						<?php 
        }
        ?>

						<?php 
        esc_html_e('Embed Url', 'gravityforms');
        ?>
:
						<a href="<?php 
        echo esc_url($lead['source_url']);
        ?>
" target="_blank" alt="<?php 
        echo esc_attr($lead['source_url']);
        ?>
" title="<?php 
        echo esc_attr($lead['source_url']);
        ?>
">.../<?php 
        echo esc_html(GFCommon::truncate_url($lead['source_url']));
        ?>
</a>
						<br /><br />
						<?php 
        if (!empty($lead['post_id'])) {
            $post = get_post($lead['post_id']);
            ?>
							<?php 
            esc_html_e('Edit Post', 'gravityforms');
            ?>
:
							<a href="post.php?action=edit&post=<?php 
            echo absint($post->ID);
            ?>
" alt="<?php 
            esc_attr_e('Click to edit post', 'gravityforms');
            ?>
" title="<?php 
            esc_attr_e('Click to edit post', 'gravityforms');
            ?>
"><?php 
            echo esc_html($post->post_title);
            ?>
</a>
							<br /><br />
						<?php 
        }
        if (do_action('gform_enable_entry_info_payment_details', true, $lead)) {
            if (!empty($lead['payment_status'])) {
                echo $lead['transaction_type'] != 2 ? esc_html__('Payment Status', 'gravityforms') : esc_html__('Subscription Status', 'gravityforms');
                ?>
:
								<span id="gform_payment_status"><?php 
                echo apply_filters('gform_payment_status', $lead['payment_status'], $form, $lead);
                ?>
</span>
								<br /><br />
								<?php 
                if (!empty($lead['payment_date'])) {
                    echo $lead['transaction_type'] != 2 ? esc_html__('Payment Date', 'gravityforms') : esc_html__('Start Date', 'gravityforms');
                    ?>
: <?php 
                    echo GFCommon::format_date($lead['payment_date'], false, 'Y/m/d', $lead['transaction_type'] != 2);
                    ?>
									<br /><br />
								<?php 
                }
                if (!empty($lead['transaction_id'])) {
                    echo $lead['transaction_type'] != 2 ? esc_html__('Transaction Id', 'gravityforms') : esc_html__('Subscriber Id', 'gravityforms');
                    ?>
: <?php 
                    echo esc_html($lead['transaction_id']);
                    ?>
									<br /><br />
								<?php 
                }
                if (!rgblank($lead['payment_amount'])) {
                    echo $lead['transaction_type'] != 2 ? esc_html__('Payment Amount', 'gravityforms') : esc_html__('Subscription Amount', 'gravityforms');
                    ?>
: <?php 
                    echo GFCommon::to_money($lead['payment_amount'], $lead['currency']);
                    ?>
									<br /><br />
								<?php 
                }
            }
        }
        do_action('gform_entry_info', $form['id'], $lead);
        ?>
					</div>
					<div id="major-publishing-actions">
						<div id="delete-action">
							<?php 
        switch ($lead['status']) {
            case 'spam':
                if (GFCommon::spam_enabled($form['id'])) {
                    ?>
										<a onclick="jQuery('#action').val('unspam'); jQuery('#entry_form').submit()" href="#"><?php 
                    esc_html_e('Not Spam', 'gravityforms');
                    ?>
</a>
										<?php 
                    echo GFCommon::current_user_can_any('gravityforms_delete_entries') ? '|' : '';
                }
                if (GFCommon::current_user_can_any('gravityforms_delete_entries')) {
                    ?>
										<a class="submitdelete deletion" onclick="if ( confirm('<?php 
                    echo esc_js(__("You are about to delete this entry. 'Cancel' to stop, 'OK' to delete.", 'gravityforms'));
                    ?>
') ) {jQuery('#action').val('delete'); jQuery('#entry_form').submit(); return true;} return false;" href="#"><?php 
                    esc_html_e('Delete Permanently', 'gravityforms');
                    ?>
</a>
									<?php 
                }
                break;
            case 'trash':
                ?>
									<a onclick="jQuery('#action').val('restore'); jQuery('#entry_form').submit()" href="#"><?php 
                esc_html_e('Restore', 'gravityforms');
                ?>
</a>
									<?php 
                if (GFCommon::current_user_can_any('gravityforms_delete_entries')) {
                    ?>
										|
										<a class="submitdelete deletion" onclick="if ( confirm('<?php 
                    echo esc_js(__("You are about to delete this entry. 'Cancel' to stop, 'OK' to delete.", 'gravityforms'));
                    ?>
') ) {jQuery('#action').val('delete'); jQuery('#entry_form').submit(); return true;} return false;" href="#"><?php 
                    esc_html_e('Delete Permanently', 'gravityforms');
                    ?>
</a>
									<?php 
                }
                break;
            default:
                if (GFCommon::current_user_can_any('gravityforms_delete_entries')) {
                    ?>
										<a class="submitdelete deletion" onclick="jQuery('#action').val('trash'); jQuery('#entry_form').submit()" href="#"><?php 
                    esc_html_e('Move to Trash', 'gravityforms');
                    ?>
</a>
										<?php 
                    echo GFCommon::spam_enabled($form['id']) ? '|' : '';
                }
                if (GFCommon::spam_enabled($form['id'])) {
                    ?>
										<a class="submitdelete deletion" onclick="jQuery('#action').val('spam'); jQuery('#entry_form').submit()" href="#"><?php 
                    esc_html_e('Mark as Spam', 'gravityforms');
                    ?>
</a>
									<?php 
                }
        }
        ?>
						</div>
						<div id="publishing-action">
							<?php 
        if (GFCommon::current_user_can_any('gravityforms_edit_entries') && $lead['status'] != 'trash') {
            $button_text = $mode == 'view' ? __('Edit', 'gravityforms') : __('Update', 'gravityforms');
            $disabled = $mode == 'view' ? '' : ' disabled="disabled" ';
            $update_button_id = $mode == 'view' ? 'gform_edit_button' : 'gform_update_button';
            $button_click = $mode == 'view' ? "jQuery('#screen_mode').val('edit');" : "jQuery('#action').val('update'); jQuery('#screen_mode').val('view');";
            $update_button = '<input id="' . $update_button_id . '" ' . $disabled . ' class="button button-large button-primary" type="submit" tabindex="4" value="' . esc_attr($button_text) . '" name="save" onclick="' . $button_click . '"/>';
            echo apply_filters('gform_entrydetail_update_button', $update_button);
            if ($mode == 'edit') {
                echo '&nbsp;&nbsp;<input class="button button-large" type="submit" tabindex="5" value="' . esc_attr__('Cancel', 'gravityforms') . '" name="cancel" onclick="jQuery(\'#screen_mode\').val(\'view\');"/>';
            }
        }
        ?>
						</div>
						<div class="clear"></div>
					</div>
				</div>
			</div>
		</div>

		<?php 
        if (!empty($lead['payment_status']) && !apply_filters('gform_enable_entry_info_payment_details', true, $lead)) {
            self::payment_details_box($lead, $form);
        }
        ?>

		<?php 
        do_action('gform_entry_detail_sidebar_middle', $form, $lead);
        ?>

		<?php 
        if (GFCommon::current_user_can_any('gravityforms_edit_entry_notes')) {
            ?>
			<!-- start notifications -->
			<div class="postbox" id="notifications_container">
				<h3 class="hndle" style="cursor:default;">
					<span><?php 
            esc_html_e('Notifications', 'gravityforms');
            ?>
</span>
				</h3>

				<div class="inside">
					<div class="message" style="display:none;padding:10px;"></div>
					<div>
						<?php 
            $notifications = GFCommon::get_notifications('resend_notifications', $form);
            if (!is_array($notifications) || count($form['notifications']) <= 0) {
                ?>
							<p class="description"><?php 
                esc_html_e('You cannot resend notifications for this entry because this form does not currently have any notifications configured.', 'gravityforms');
                ?>
</p>

							<a href="<?php 
                echo admin_url("admin.php?page=gf_edit_forms&view=settings&subview=notification&id={$form_id}");
                ?>
" class="button"><?php 
                esc_html_e('Configure Notifications', 'gravityforms');
                ?>
</a>
						<?php 
            } else {
                foreach ($notifications as $notification) {
                    ?>
								<input type="checkbox" class="gform_notifications" value="<?php 
                    echo esc_attr($notification['id']);
                    ?>
" id="notification_<?php 
                    echo esc_attr($notification['id']);
                    ?>
" onclick="toggleNotificationOverride();" />
								<label for="notification_<?php 
                    echo esc_attr($notification['id']);
                    ?>
"><?php 
                    echo esc_html($notification['name']);
                    ?>
</label>
								<br /><br />
							<?php 
                }
                ?>

							<div id="notifications_override_settings" style="display:none;">

								<p class="description" style="padding-top:0; margin-top:0; width:99%;">You may override the default notification settings
									by entering a comma delimited list of emails to which the selected notifications should be sent.</p>
								<label for="notification_override_email"><?php 
                esc_html_e('Send To', 'gravityforms');
                ?>
 <?php 
                gform_tooltip('notification_override_email');
                ?>
</label><br />
								<input type="text" name="notification_override_email" id="notification_override_email" style="width:99%;" />
								<br /><br />

							</div>

							<input type="button" name="notification_resend" value="<?php 
                esc_attr_e('Resend Notifications', 'gravityforms');
                ?>
" class="button" style="" onclick="ResendNotifications();" />
							<span id="please_wait_container" style="display:none; margin-left: 5px;">
								<i class='gficon-gravityforms-spinner-icon gficon-spin'></i> <?php 
                esc_html_e('Resending...', 'gravityforms');
                ?>
                            </span>
						<?php 
            }
            ?>

					</div>
				</div>
			</div>
			<!-- / end notifications -->
		<?php 
        }
        ?>

		<!-- begin print button -->
		<div class="detail-view-print">
			<a href="javascript:;" onclick="var notes_qs = jQuery('#gform_print_notes').is(':checked') ? '&notes=1' : ''; var url='<?php 
        echo trailingslashit(site_url());
        ?>
?gf_page=print-entry&fid=<?php 
        echo absint($form['id']);
        ?>
&lid=<?php 
        echo absint($lead['id']);
        ?>
' + notes_qs; window.open (url,'printwindow');" class="button"><?php 
        esc_html_e('Print', 'gravityforms');
        ?>
</a>
			<?php 
        if (GFCommon::current_user_can_any('gravityforms_view_entry_notes')) {
            ?>
				<input type="checkbox" name="print_notes" value="print_notes" checked="checked" id="gform_print_notes" />
				<label for="print_notes"><?php 
            esc_html_e('include notes', 'gravityforms');
            ?>
</label>
			<?php 
        }
        ?>
		</div>
		<!-- end print button -->
		<?php 
        do_action('gform_entry_detail_sidebar_after', $form, $lead);
        ?>
		</div>

		<div id="post-body" class="has-sidebar">
			<div id="post-body-content" class="has-sidebar-content">
				<?php 
        do_action('gform_entry_detail_content_before', $form, $lead);
        if ($mode == 'view') {
            self::lead_detail_grid($form, $lead, true);
        } else {
            self::lead_detail_edit($form, $lead);
        }
        do_action('gform_entry_detail', $form, $lead);
        if (GFCommon::current_user_can_any('gravityforms_view_entry_notes')) {
            ?>
					<div class="postbox">
						<h3>
							<label for="name"><?php 
            esc_html_e('Notes', 'gravityforms');
            ?>
</label>
						</h3>

						<form method="post">
							<?php 
            wp_nonce_field('gforms_update_note', 'gforms_update_note');
            ?>
							<div class="inside">
								<?php 
            $notes = RGFormsModel::get_lead_notes($lead['id']);
            //getting email values
            $email_fields = GFCommon::get_email_fields($form);
            $emails = array();
            foreach ($email_fields as $email_field) {
                if (!empty($lead[$email_field->id])) {
                    $emails[] = $lead[$email_field->id];
                }
            }
            //displaying notes grid
            $subject = '';
            self::notes_grid($notes, true, $emails, $subject);
            ?>
							</div>
						</form>
					</div>
				<?php 
        }
        do_action('gform_entry_detail_content_after', $form, $lead);
        ?>
			</div>
		</div>
		</div>
		</div>
		</form>
		<?php 
        if (rgpost('action') == 'update') {
            ?>
			<div class="updated fade" style="padding:6px;">
				<?php 
            esc_html_e('Entry Updated.', 'gravityforms');
            ?>
			</div>
		<?php 
        }
    }
 /**
  * Trims values from elements e.g. fields, notifications and confirmations
  *
  * @param array $element Form object.
  * @param array $form    Form object.
  * @param bool  $updated Output parameter.
  *
  * @return array $element
  */
 public static function trim_conditional_logic_values_from_element($element, $form = array(), &$updated = false)
 {
     if ($element instanceof GF_Field) {
         /* @var GF_Field $element */
         if (is_array($element->conditionalLogic) && isset($element->conditionalLogic['rules']) && is_array($element->conditionalLogic['rules'])) {
             foreach ($element->conditionalLogic['rules'] as &$rule) {
                 $value = (string) $rule['value'];
                 if ($value !== trim($value)) {
                     $field = isset($form['fields']) ? GFFormsModel::get_field($form, $rule['fieldId']) : array();
                     $trim_value = apply_filters('gform_trim_input_value', true, rgar($form, 'id'), $field);
                     if ($trim_value) {
                         $rule['value'] = trim($rule['value']);
                         $updated = true;
                     }
                 }
             }
         }
     } else {
         if (isset($element['conditionalLogic']) && is_array($element['conditionalLogic']) && isset($element['conditionalLogic']['rules']) && is_array($element['conditionalLogic']['rules'])) {
             foreach ($element['conditionalLogic']['rules'] as &$rule) {
                 $value = (string) $rule['value'];
                 if ($value !== trim($value)) {
                     $field = isset($form['fields']) ? GFFormsModel::get_field($form, $rule['fieldId']) : array();
                     $trim_value = apply_filters('gform_trim_input_value', true, rgar($form, 'id'), $field);
                     if ($trim_value) {
                         $rule['value'] = trim($rule['value']);
                         $updated = true;
                     }
                 }
             }
         }
     }
     return $element;
 }
示例#30
0
 /**
  * Saves form meta. Note the special requirements for the meta string.
  *
  * @param        $id
  * @param string $form_json A valid JSON string. The JSON is manipulated before decoding and is designed to work together with jQuery.toJSON() rather than json_encode. Avoid using json_encode as it will convert unicode characters into their respective entities with slashes. These slashes get stripped so unicode characters won't survive intact.
  *
  * @return array
  */
 public static function save_form_info($id, $form_json)
 {
     global $wpdb;
     $form_json = stripslashes($form_json);
     $form_json = nl2br($form_json);
     GFCommon::log_debug('GFFormDetail::save_form_info(): Form meta json: ' . $form_json);
     $form_meta = json_decode($form_json, true);
     $form_meta = GFFormsModel::convert_field_objects($form_meta);
     GFCommon::log_debug('GFFormDetail::save_form_info(): Form meta => ' . print_r($form_meta, true));
     if (!$form_meta) {
         return array('status' => 'invalid_json', 'meta' => null);
     }
     $form_table_name = $wpdb->prefix . 'rg_form';
     //Making sure title is not duplicate
     $forms = RGFormsModel::get_forms();
     foreach ($forms as $form) {
         if (strtolower($form->title) == strtolower($form_meta['title']) && rgar($form_meta, 'id') != $form->id) {
             return array('status' => 'duplicate_title', 'meta' => $form_meta);
         }
     }
     if ($id > 0) {
         $form_meta = GFFormsModel::trim_form_meta_values($form_meta);
         RGFormsModel::update_form_meta($id, $form_meta);
         //updating form title
         $wpdb->query($wpdb->prepare("UPDATE {$form_table_name} SET title=%s WHERE id=%d", $form_meta['title'], $form_meta['id']));
         $form_meta = RGFormsModel::get_form_meta($id);
         do_action('gform_after_save_form', $form_meta, false);
         return array('status' => $id, 'meta' => $form_meta);
     } else {
         //inserting form
         $id = RGFormsModel::insert_form($form_meta['title']);
         //updating object's id property
         $form_meta['id'] = $id;
         //creating default notification
         if (apply_filters('gform_default_notification', true)) {
             $default_notification = array('id' => uniqid(), 'to' => '{admin_email}', 'name' => __('Admin Notification', 'gravityforms'), 'event' => 'form_submission', 'toType' => 'email', 'subject' => __('New submission from', 'gravityforms') . ' {form_title}', 'message' => '{all_fields}');
             $notifications = array($default_notification['id'] => $default_notification);
             //updating notifications form meta
             RGFormsModel::save_form_notifications($id, $notifications);
         }
         // add default confirmation when saving a new form
         $confirmation_id = uniqid();
         $confirmations = array();
         $confirmations[$confirmation_id] = array('id' => $confirmation_id, 'name' => __('Default Confirmation', 'gravityforms'), 'isDefault' => true, 'type' => 'message', 'message' => __('Thanks for contacting us! We will get in touch with you shortly.', 'gravityforms'), 'url' => '', 'pageId' => '', 'queryString' => '');
         GFFormsModel::save_form_confirmations($id, $confirmations);
         //updating form meta
         RGFormsModel::update_form_meta($id, $form_meta);
         $form_meta = RGFormsModel::get_form_meta($id);
         do_action('gform_after_save_form', $form_meta, true);
         return array('status' => $id * -1, 'meta' => $form_meta);
     }
 }