Пример #1
0
 public static function update($field_options, $field, $values)
 {
     $defaults = FrmProFieldsHelper::get_default_field_opts(false, $field);
     unset($defaults['post_field'], $defaults['custom_field'], $defaults['taxonomy'], $defaults['exclude_cat']);
     $defaults['minnum'] = 0;
     $defaults['maxnum'] = 9999;
     foreach ($defaults as $opt => $default) {
         $field_options[$opt] = isset($values['field_options'][$opt . '_' . $field->id]) ? $values['field_options'][$opt . '_' . $field->id] : $default;
         unset($opt, $default);
     }
     foreach ($field_options['hide_field'] as $i => $f) {
         if (empty($f)) {
             unset($field_options['hide_field'][$i], $field_options['hide_field_cond'][$i]);
             if (isset($field_options['hide_opt']) && is_array($field_options['hide_opt'])) {
                 unset($field_options['hide_opt'][$i]);
             }
         }
         unset($i, $f);
     }
     if ($field->type == 'scale') {
         if ((int) $field_options['maxnum'] >= 99) {
             $field_options['maxnum'] = 10;
         }
         $options = range($field_options['minnum'], $field_options['maxnum']);
         FrmField::update($field->id, array('options' => serialize($options)));
     } else {
         if ($field->type == 'hidden' && isset($field_options['required']) && $field_options['required']) {
             $field_options['required'] = false;
         }
     }
     return $field_options;
 }
 /**
  * @covers FrmProFieldsHelper::convert_to_static_year
  * Check if dynamic year (in date field) is converted to static correctly
  */
 function test_convert_to_static_year()
 {
     $values_to_test = array('', '0', '-10', '-100', '10', '+10', '+100', '1900', '2015');
     foreach ($values_to_test as $dynamic_val) {
         $year = FrmProFieldsHelper::convert_to_static_year($dynamic_val);
         $this->assertTrue(strlen($year) == 4 && is_numeric($year) && strpos($year, '-') === false && strpos($year, '+') === false, 'The dynamic value ' . $dynamic_val . ' was not correctly converted to a year. It was converted to: ' . $year);
     }
 }
 function check_dependent_taxonomies()
 {
     $parent_field = $this->factory->field->get_object_by_id('parent-dynamic-taxonomy');
     $child_field = $this->factory->field->get_object_by_id('child-dynamic-taxonomy');
     $parent_options = FrmProFieldsHelper::get_category_options($parent_field);
     $this->assertNotEmpty($parent_options);
     $parent_category = array_search('Altered Thurzdaze', $parent_options);
     $parent_category2 = array_search('Estate Info', $parent_options);
     $response = $this->get_dependent_data_response(array('parent_field' => $parent_field, 'selected_option' => array($parent_category, $parent_category2), 'child_field' => $child_field));
     // we are expecting 2 child categories in the select options
     preg_match_all('@<option value=\\"(.*)\\">(.*)</option>@', $response, $matches);
     $this->assertEquals(count($matches[0]), 3);
     $grandchild_field = $this->factory->field->get_object_by_id('grandchild-dynamic-taxonomy');
     $response = $this->get_dependent_data_response(array('parent_field' => $child_field, 'selected_option' => $matches[1][1], 'child_field' => $grandchild_field));
     preg_match_all('@<input type="checkbox" (.*) />@', $response, $matches);
     $this->assertEquals(count($matches[0]), 1);
 }
Пример #4
0
selected($order_by, 'updated_at');
?>
><?php 
_e('Entry update date', 'formidable');
?>
</option>
        <option value="rand" <?php 
selected($order_by, 'rand');
?>
><?php 
_e('Random', 'formidable');
?>
</option>
        <?php 
if (is_numeric($form_id)) {
    FrmProFieldsHelper::get_field_options($form_id, $order_by);
}
?>
    </select>

    <select id="order" name="options[order][<?php 
echo esc_attr($order_key);
?>
]">
        <option value="ASC" <?php 
selected($order, 'ASC');
?>
><?php 
_e('Ascending', 'formidable');
?>
</option>
Пример #5
0
" id="field_<?php 
                                        echo $field['field_key'];
                                        ?>
" <?php 
                                        do_action('frm_field_input_html', $field);
                                        ?>
 /><br/>
<input type="hidden" name="<?php 
                                        echo $field_name;
                                        ?>
" value="<?php 
                                        echo esc_attr(is_array($field['value']) ? reset($field['value']) : $field['value']);
                                        ?>
" />
<?php 
                                        echo FrmProFieldsHelper::get_file_icon($field['value']);
                                    }
                                }
                                include_once FrmAppHelper::plugin_path() . '/pro/classes/views/frmpro-entries/loading.php';
                            } else {
                                if ($field['type'] == 'data') {
                                    ?>
<div id="frm_data_field_<?php 
                                    echo $field['id'];
                                    ?>
_container">
<?php 
                                    require FrmAppHelper::plugin_path() . '/pro/classes/views/frmpro-fields/data-options.php';
                                    ?>
</div>
<?php 
Пример #6
0
selected($values['order_by'], 'created_at');
?>
><?php 
_e('Entry creation date', 'formidable');
?>
</option>
                <option value="updated_at" <?php 
selected($values['order_by'], 'updated_at');
?>
><?php 
_e('Entry update date', 'formidable');
?>
</option>
                <?php 
if (is_numeric($values['form_id'])) {
    FrmProFieldsHelper::get_field_options($values['form_id'], $values['order_by']);
}
?>
            </select>    

            <select id="order" name="options[order]">
                <option value=""></option>
                <option value="ASC" <?php 
selected($values['order'], 'ASC');
?>
><?php 
_e('Ascending', 'formidable');
?>
</option>
                <option value="DESC" <?php 
selected($values['order'], 'DESC');
Пример #7
0
            <span class="dashicons dashicons-admin-users wp-media-buttons-icon"></span>
			<?php 
        printf(__('Created by: %1$s', 'formidable'), FrmProFieldsHelper::get_display_name($entry->user_id, 'display_name', array('link' => true)));
        ?>
        </div>
        <?php 
    }
    ?>

        <?php 
    if ($entry->updated_by && $entry->updated_by != $entry->user_id) {
        ?>
        <div class="misc-pub-section">
            <span class="dashicons dashicons-admin-users wp-media-buttons-icon"></span>
			<?php 
        printf(__('Updated by: %1$s', 'formidable'), FrmProFieldsHelper::get_display_name($entry->updated_by, 'display_name', array('link' => true)));
        ?>
        </div>
        <?php 
    }
    ?>
        <?php 
}
?>

    </div>
</div>

<div class="postbox">
    <h3 class="hndle"><span><?php 
_e('User Information', 'formidable');
 function _get_dynamic_fields_args()
 {
     $args = array();
     // Get the Dynamic field
     $field_id = FrmField::get_id_by_key('dynamic-state');
     $args['field'] = FrmField::getOne($field_id);
     // Get the Parent field
     $parent_field_id = FrmField::get_id_by_key('dynamic-country');
     $args['parent_field'] = FrmField::getOne($parent_field_id);
     $values = array('hide_field' => array(), 'form_select' => $args['parent_field']->field_options['form_select'], 'restrict' => '');
     $args['parent_options'] = FrmProFieldsHelper::get_linked_options($values, $args['field'], '');
     foreach ($args['parent_options'] as $key => $opt) {
         if ($opt == 'United States') {
             $args['us_id'] = $key;
             break;
         }
     }
     self::_get_the_join_field($args);
     self::_get_the_expected_dynamic_field_entry_ids($args);
     self::_get_the_prev_val($args);
     return $args;
 }
 public static function do_mergetags($string, $form_id, $entry_id)
 {
     global $frm_entry;
     /* strip {all_fields} merge tag from $string */
     $string = str_replace('[default-message]', '', $string);
     $entry = $frm_entry->getOne($entry_id, true);
     $shortcodes = FrmProAppHelper::get_shortcodes($string, $form_id);
     return FrmProFieldsHelper::replace_shortcodes($string, $entry, $shortcodes);
 }
Пример #10
0
if (!$new_field) {
    return;
}
if ($new_field->type == 'data') {
    if (isset($new_field->field_options['form_select']) && is_numeric($new_field->field_options['form_select'])) {
        $new_entries = $frm_entry_meta->getAll("it.field_id=" . $new_field->field_options['form_select']);
    }
    $new_field->options = array();
    if (isset($new_entries) && !empty($new_entries)) {
        foreach ($new_entries as $ent) {
            $new_field->options[$ent->item_id] = $ent->meta_value;
        }
    }
} else {
    if (isset($new_field->field_options['post_field']) and $new_field->field_options['post_field'] == 'post_status') {
        $new_field->options = FrmProFieldsHelper::get_status_options($new_field);
    } else {
        $new_field->options = stripslashes_deep(maybe_unserialize($new_field->options));
    }
}
if (isset($new_field->field_options['post_field']) and $new_field->field_options['post_field'] == 'post_category') {
    $new_field = (array) $new_field;
    $new_field['value'] = (isset($field) and isset($field['hide_opt'][$meta_name])) ? $field['hide_opt'][$meta_name] : '';
    $new_field['exclude_cat'] = isset($new_field->field_options['exclude_cat']) ? $new_field->field_options['exclude_cat'] : '';
    echo FrmFieldsHelper::dropdown_categories(array('name' => "field_options[hide_opt_{$current_field_id}][]", 'id' => "field_options[hide_opt_{$current_field_id}]", 'field' => $new_field));
} else {
    $temp_field = (array) $new_field;
    foreach ($new_field->field_options as $fkey => $fval) {
        $temp_field[$fkey] = $fval;
        unset($fkey);
        unset($fval);
Пример #11
0
 public static function is_field_hidden($field, $values)
 {
     global $frm_field;
     $field->field_options = maybe_unserialize($field->field_options);
     if ($field->type == 'user_id' or $field->type == 'hidden') {
         return false;
     }
     if (!isset($field->field_options['hide_field']) or empty($field->field_options['hide_field'])) {
         return false;
     }
     //TODO: check if field is included in conditional heading
     $field->field_options['hide_field'] = (array) $field->field_options['hide_field'];
     if (!isset($field->field_options['hide_field_cond'])) {
         $field->field_options['hide_field_cond'] = array('==');
     }
     $field->field_options['hide_field_cond'] = (array) $field->field_options['hide_field_cond'];
     $field->field_options['hide_opt'] = (array) $field->field_options['hide_opt'];
     if (!isset($field->field_options['show_hide'])) {
         $field->field_options['show_hide'] = 'show';
     }
     if (!isset($field->field_options['any_all'])) {
         $field->field_options['any_all'] = 'any';
     }
     $hidden = false;
     $hide = array();
     foreach ($field->field_options['hide_field'] as $hide_key => $hide_field) {
         if ($hidden and $field->field_options['any_all'] == 'any' and $field->field_options['show_hide'] == 'hide') {
             continue;
         }
         $observed_value = isset($values['item_meta'][$hide_field]) ? $values['item_meta'][$hide_field] : '';
         if ($field->type == 'data' and empty($field->field_options['hide_opt'][$hide_key]) and (is_numeric($observed_value) or is_array($observed_value))) {
             $observed_field = $frm_field->getOne($hide_field);
             if ($observed_field->type == 'data') {
                 $field->field_options['hide_opt'][$hide_key] = $observed_value;
             }
             unset($observed_field);
         }
         $hidden = FrmProFieldsHelper::value_meets_condition($observed_value, $field->field_options['hide_field_cond'][$hide_key], $field->field_options['hide_opt'][$hide_key]);
         if ($field->field_options['show_hide'] == 'show') {
             $hidden = $hidden ? false : true;
         }
         $hide[$hidden] = $hidden;
     }
     if ($field->field_options['any_all'] == 'all' and !empty($hide) and isset($hide[0]) and isset($hide[1])) {
         $hidden = $field->field_options['show_hide'] == 'show' ? true : false;
     } else {
         if ($field->field_options['any_all'] == 'any' and $field->field_options['show_hide'] == 'show' and isset($hide[0])) {
             $hidden = false;
         }
     }
     return $hidden;
 }
Пример #12
0
 public static function get_field_value_shortcode($atts)
 {
     extract(shortcode_atts(array('entry_id' => false, 'field_id' => false, 'user_id' => false, 'ip' => false, 'show' => '', 'format' => ''), $atts));
     if (!$field_id) {
         return __('You are missing options in your shortcode. field_id is required.', 'formidable');
     }
     global $frm_field, $wpdb, $frmdb;
     $field = $frm_field->getOne($field_id);
     if (!$field) {
         return '';
     }
     $query = $wpdb->prepare("SELECT post_id, id FROM {$frmdb->entries} WHERE form_id=%d", $field->form_id);
     if ($user_id) {
         // make sure we are not getting entries for logged-out users
         $query .= $wpdb->prepare(' AND user_id=%d AND user_id > 0', (int) FrmProAppHelper::get_user_id_param($user_id));
     }
     if ($entry_id) {
         if (!is_numeric($entry_id)) {
             $entry_id = isset($_GET[$entry_id]) ? $_GET[$entry_id] : $entry_id;
         }
         if ((int) $entry_id < 1) {
             // don't run the sql query if we know there will be no results
             return;
         }
         $query .= $wpdb->prepare(' AND id=%d', (int) $entry_id);
     }
     if ($ip) {
         $query .= $wpdb->prepare(' AND ip=%s', $ip == true ? $_SERVER['REMOTE_ADDR'] : $ip);
     }
     $query .= " ORDER BY created_at DESC LIMIT 1";
     $entry = $wpdb->get_row($query);
     if (!$entry) {
         return;
     }
     $value = FrmProEntryMetaHelper::get_post_or_meta_value($entry, $field, $atts);
     $atts['type'] = $field->type;
     $atts['post_id'] = $entry->post_id;
     $atts['entry_id'] = $entry->id;
     if (!isset($atts['show_filename'])) {
         $atts['show_filename'] = false;
     }
     if (isset($show) and !empty($show)) {
         $atts['show'] = $show;
         $value = FrmProFieldsHelper::get_display_value($value, $field, $atts);
     } else {
         $value = FrmProEntryMetaHelper::display_value($value, $field, $atts);
     }
     return $value;
 }
Пример #13
0
                    <h3 class="hndle"><span><?php 
    _e('Comments/Notes', 'formidable');
    ?>
</span></h3>
                    <div class="inside">
                        <table class="form-table"><tbody> 
                        <?php 
    foreach ($comments as $comment) {
        $meta = $comment->meta_value;
        if (!isset($meta['comment'])) {
            continue;
        }
        ?>
                            <tr class="frm_comment_block">
                                <th scope="row"><p><strong><?php 
        echo FrmProFieldsHelper::get_display_name($meta['user_id'], 'display_name', array('link' => true));
        ?>
</strong><br/>
                                    <?php 
        echo FrmProAppHelper::get_formatted_time($comment->created_at, $date_format, $time_format);
        ?>
</p>
                                </th>
                                <td><div class="frm_comment"><?php 
        echo wpautop(strip_tags($meta['comment']));
        ?>
</div></td>
                            </tr>
                        <?php 
    }
    ?>
Пример #14
0
 public static function populate_calc_dropdown()
 {
     if (isset($_POST['form_id']) and isset($_POST['field_id'])) {
         echo FrmProFieldsHelper::get_shortcode_select($_POST['form_id'], 'frm_calc_' . $_POST['field_id'], 'calc');
     }
     die;
 }
Пример #15
0
                        <input type="text" name="options[success_url]" id="success_url" value="<?php 
echo esc_attr($values['success_url']);
?>
" size="55"></td>
                </tr>
                
                <tr class="success_action_message_box success_action_box" <?php 
echo $values['success_action'] == 'page' ? 'style="display:none;"' : '';
?>
><td valign="top"><label><?php 
_e('Confirmation Message', 'formidable');
?>
</label></td>
                    <td><?php 
if ($frmpro_is_installed and isset($values['id'])) {
    FrmProFieldsHelper::get_shortcode_select($values['id'], 'success_msg');
    echo '<br/>';
}
?>
                        <textarea id="success_msg" name="options[success_msg]" cols="50" rows="4" class="frm_long_input"><?php 
echo FrmAppHelper::esc_textarea($values['success_msg']);
?>
</textarea> <br/>
                    <div class="frm_show_form_opt" <?php 
echo $values['success_action'] == 'redirect' ? 'style="display:none;"' : '';
?>
>
                    <input type="checkbox" name="options[show_form]" id="show_form" value="1" <?php 
checked($values['show_form'], 1);
?>
 /> <label for="show_form"><?php 
 function display_value($value, $field, $atts = array())
 {
     global $wpdb;
     $defaults = array('type' => '', 'show_icon' => true, 'show_filename' => true, 'truncate' => false, 'sep' => ', ', 'post_id' => 0, 'form_id' => $field->form_id, 'field' => $field);
     $atts = wp_parse_args($atts, $defaults);
     $field->field_options = maybe_unserialize($field->field_options);
     if (!isset($field->field_options['post_field'])) {
         $field->field_options['post_field'] = '';
     }
     if (!isset($field->field_options['custom_field'])) {
         $field->field_options['custom_field'] = '';
     }
     if ($atts['post_id'] and ($field->field_options['post_field'] or $atts['type'] == 'tag')) {
         $atts['pre_truncate'] = $atts['truncate'];
         $atts['truncate'] = true;
         $atts['exclude_cat'] = isset($field->field_options['exclude_cat']) ? $field->field_options['exclude_cat'] : 0;
         $value = FrmProEntryMetaHelper::get_post_value($atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts);
         $atts['truncate'] = $atts['pre_truncate'];
     }
     if ($value == '') {
         return $value;
     }
     $value = maybe_unserialize($value);
     if (is_array($value)) {
         $value = stripslashes_deep($value);
     }
     $value = apply_filters('frm_display_value_custom', $value, $field, $atts);
     $new_value = '';
     if (is_array($value)) {
         foreach ($value as $val) {
             if (is_array($val)) {
                 //TODO: add options for display (li or ,)
                 $new_value .= implode($atts['sep'], $val);
                 if ($atts['type'] != 'data') {
                     $new_value .= "<br/>";
                 }
             }
             unset($val);
         }
     }
     if (!empty($new_value)) {
         $value = $new_value;
     } else {
         if (is_array($value)) {
             $value = implode($atts['sep'], $value);
         }
     }
     if ($atts['truncate'] and $atts['type'] != 'image') {
         $value = FrmAppHelper::truncate($value, 50);
     }
     if ($atts['type'] == 'image') {
         $value = '<img src="' . $value . '" height="50px" alt="" />';
     } else {
         if ($atts['type'] == 'user_id') {
             $value = FrmProFieldsHelper::get_display_name($value);
         } else {
             if ($atts['type'] == 'file') {
                 $old_value = $value;
                 $value = '';
                 if ($atts['show_icon']) {
                     $value .= FrmProFieldsHelper::get_file_icon($old_value);
                 }
                 if ($atts['show_icon'] and $atts['show_filename']) {
                     $value .= '<br/>';
                 }
                 if ($atts['show_filename']) {
                     $value .= FrmProFieldsHelper::get_file_name($old_value);
                 }
             } else {
                 if ($atts['type'] == 'date') {
                     $value = FrmProFieldsHelper::get_date($value);
                 } else {
                     if ($atts['type'] == 'data') {
                         if (!is_numeric($value)) {
                             $value = explode($atts['sep'], $value);
                             if (is_array($value)) {
                                 $new_value = '';
                                 foreach ($value as $entry_id) {
                                     if (!empty($new_value)) {
                                         $new_value .= $atts['sep'];
                                     }
                                     if (is_numeric($entry_id)) {
                                         $new_value .= FrmProFieldsHelper::get_data_value($entry_id, $field, $atts);
                                     } else {
                                         $new_value .= $entry_id;
                                     }
                                 }
                                 $value = $new_value;
                             }
                         } else {
                             //replace item id with specified field
                             $value = FrmProFieldsHelper::get_data_value($value, $field, $atts);
                             if ($field->field_options['data_type'] == 'data' or $field->field_options['data_type'] == '') {
                                 $linked_field = FrmField::getOne($field->field_options['form_select']);
                                 if ($linked_field->type == 'file') {
                                     $old_value = $value;
                                     $value = '<img src="' . $value . '" height="50px" alt="" />';
                                     if ($atts['show_filename']) {
                                         $value .= '<br/>' . $old_value;
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     $value = stripslashes_deep($value);
     return apply_filters('frm_display_value', $value, $field, $atts);
 }
Пример #17
0
 public static function replace_content_shortcodes($content, $entry, $shortcodes)
 {
     remove_filter('frm_replace_content_shortcodes', 'FrmFormsController::replace_content_shortcodes', 20);
     return FrmProFieldsHelper::replace_shortcodes($content, $entry, $shortcodes);
 }
Пример #18
0
             $field_value = FrmProFieldsHelper::get_date($field_value, $wp_date_format);
         } else {
             if ($col->type == 'data' && is_numeric($field_value)) {
                 $field_value = FrmProFieldsHelper::get_data_value($field_value, $col);
                 //replace entry id with specified field
             } else {
                 $checked_values = maybe_unserialize($field_value);
                 $checked_values = apply_filters('frm_csv_value', $checked_values, array('field' => $col));
                 if (is_array($checked_values)) {
                     if ($col->type == 'data') {
                         $field_value = '';
                         foreach ($checked_values as $checked_value) {
                             if (!empty($field_value)) {
                                 $field_value .= ', ';
                             }
                             $field_value .= FrmProFieldsHelper::get_data_value($checked_value, $col);
                         }
                     } else {
                         $field_value = implode(', ', $checked_values);
                     }
                 } else {
                     $field_value = $checked_values;
                 }
                 $field_value = FrmProEntriesHelper::encode_value($field_value, $charset, $to_encoding);
                 $field_value = str_replace('"', '""', stripslashes($field_value));
                 //escape for CSV files.
             }
         }
     }
 }
 $field_value = str_replace(array("\r\n", "\r", "\n"), ' <br/>', $field_value);
 function autoresponder($entry_id, $form_id)
 {
     if (defined('WP_IMPORTING')) {
         return;
     }
     global $frm_form, $frm_entry, $frm_entry_meta, $frm_notification;
     $form = $frm_form->getOne($form_id);
     $form_options = maybe_unserialize($form->options);
     if (!isset($form_options['auto_responder']) or !$form_options['auto_responder'] or !isset($form_options['ar_email_message']) or $form_options['ar_email_message'] == '') {
         return;
     }
     //don't continue forward unless a message has been inserted
     $entry = $frm_entry->getOne($entry_id, true);
     $entry_ids = array($entry->id);
     $email_field = isset($form_options['ar_email_to']) ? $form_options['ar_email_to'] : 0;
     if (preg_match('/|/', $email_field)) {
         $email_fields = explode('|', $email_field);
         if (isset($email_fields[1])) {
             if (isset($entry->metas[$email_fields[0]])) {
                 $add_id = $entry->metas[$email_fields[0]];
                 $add_id = maybe_unserialize($add_id);
                 if (is_array($add_id)) {
                     foreach ($add_id as $add) {
                         $entry_ids[] = $add;
                     }
                 } else {
                     $entry_ids[] = $add_id;
                 }
             }
             $email_field = $email_fields[1];
         }
         unset($email_fields);
     }
     $inc_fields = array();
     foreach (array($email_field) as $inc_field) {
         if ($inc_field) {
             $inc_fields[] = $inc_field;
         }
     }
     $where = "it.item_id in (" . implode(',', $entry_ids) . ")";
     if (!empty($inc_fields)) {
         $inc_fields = implode(',', $inc_fields);
         $where .= " and it.field_id in ({$inc_fields})";
     }
     $values = $frm_entry_meta->getAll($where, " ORDER BY fi.field_order");
     $plain_text = (isset($form_options['ar_plain_text']) and $form_options['ar_plain_text']) ? true : false;
     $message = apply_filters('frm_ar_message', $form_options['ar_email_message'], array('entry' => $entry, 'form' => $form));
     $shortcodes = FrmProAppHelper::get_shortcodes($message, $form_id);
     $mail_body = FrmProFieldsHelper::replace_shortcodes($message, $entry, $shortcodes);
     $frm_blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
     $reply_to_name = isset($form_options['ar_reply_to_name']) ? $form_options['ar_reply_to_name'] : $frm_blogname;
     //default sender name
     $reply_to = isset($form_options['ar_reply_to']) ? $form_options['ar_reply_to'] : '[admin_email]';
     //default sender email
     foreach ($values as $value) {
         /*
                     if((int)$reply_field == $value->field_id){
                         if($value->field_type == 'user_id'){
                             $user_data = get_userdata($value->meta_value);
                             $reply_to = $user_data->user_email;
                         }else{
                             $val = apply_filters('frm_email_value', maybe_unserialize($value->meta_value), $value, $entry);
                             if(is_email($val))
                                 $reply_to = $val;
                         }
                     }
                     
                     if((int)$reply_name_field == $value->field_id){
                         if($value->field_type == 'user_id'){
                             $user_data = get_userdata($value->meta_value);
                             $reply_to_name = $user_data->display_name;
                         }else
                             $reply_to_name = apply_filters('frm_email_value', maybe_unserialize($value->meta_value), $value, $entry);
                     } */
         if ((int) $email_field == $value->field_id) {
             if ($value->field_type == 'user_id') {
                 $user_data = get_userdata($value->meta_value);
                 $to_email = $user_data->user_email;
             } else {
                 $val = apply_filters('frm_email_value', maybe_unserialize($value->meta_value), $value, $entry);
                 if (is_email($val)) {
                     $to_email = $val;
                 }
             }
         }
     }
     if (!isset($to_email)) {
         return;
     }
     if (isset($form_options['ar_email_subject']) and $form_options['ar_email_subject'] != '') {
         $shortcodes = FrmProAppHelper::get_shortcodes($form_options['ar_email_subject'], $form_id);
         $subject = FrmProFieldsHelper::replace_shortcodes($form_options['ar_email_subject'], $entry, $shortcodes);
     } else {
         $subject = sprintf(__('%1$s Form submitted on %2$s', 'formidable'), stripslashes($form->name), $frm_blogname);
         //subject
     }
     $attachments = apply_filters('frm_autoresponder_attachment', array(), $form);
     $frm_notification->send_notification_email($to_email, $subject, $mail_body, $reply_to, $reply_to_name, $plain_text, $attachments);
     return $to_email;
 }
Пример #20
0
        echo $entry->parent_item_id;
        ?>
</parent_item_id>
        
<?php 
        $metas = $wpdb->get_results($wpdb->prepare("SELECT meta_value, field_id FROM {$wpdb->prefix}frm_item_metas WHERE item_id=%d", $entry->id));
        foreach ($metas as $meta) {
            ?>
		<item_meta>
		    <field_id><?php 
            echo $meta->field_id;
            ?>
</field_id>
		    <meta_value><?php 
            if (isset($fields[$meta->field_id])) {
                $meta->meta_value = FrmProFieldsHelper::get_export_val($meta->meta_value, $fields[$meta->field_id]);
            }
            echo FrmXMLHelper::cdata($meta->meta_value);
            unset($meta);
            ?>
</meta_value>
		</item_meta>
<?php 
        }
        ?>
	</item>
<?php 
        unset($metas);
        if (!empty($entry->post_id)) {
            $old_ids = $item_ids;
            $item_ids = array($entry->post_id);
Пример #21
0
 public static function set_post_fields($field, $value, $errors = null)
 {
     $field->field_options = maybe_unserialize($field->field_options);
     if (!isset($field->field_options['post_field']) || $field->field_options['post_field'] == '') {
         if (isset($errors)) {
             return $errors;
         }
         return;
     }
     if ($field->type == 'file') {
         global $frm_vars;
         if (!isset($frm_vars['media_id'])) {
             $frm_vars['media_id'] = array();
         }
         $frm_vars['media_id'][$field->id] = $value;
     }
     global $frmpro_settings;
     if ($value && !empty($value) && isset($field->field_options['unique']) && $field->field_options['unique']) {
         global $frmdb;
         $entry_id = isset($_POST) && isset($_POST['id']) ? $_POST['id'] : false;
         $post_id = $entry_id ? $frmdb->get_var($frmdb->entries, array('id' => $entry_id), 'post_id') : false;
         if (isset($errors) && FrmProEntryMetaHelper::post_value_exists($field->field_options['post_field'], $value, $post_id, $field->field_options['custom_field'])) {
             $errors['field' . $field->id] = FrmProFieldsHelper::get_error_msg($field, 'unique_msg');
         }
         unset($entry_id);
         unset($post_id);
     }
     if ($field->field_options['post_field'] == 'post_custom') {
         if ($field->type == 'date' and !preg_match('/^\\d{4}-\\d{2}-\\d{2}/', trim($value))) {
             $value = FrmProAppHelper::convert_date($value, $frmpro_settings->date_format, 'Y-m-d');
         }
         $_POST['frm_wp_post_custom'][$field->id . '=' . $field->field_options['custom_field']] = $value;
         if (isset($errors)) {
             return $errors;
         }
         return;
     }
     if ($field->field_options['post_field'] == 'post_date') {
         if (!preg_match('/^\\d{4}-\\d{2}-\\d{2}/', trim($value))) {
             $value = FrmProAppHelper::convert_date($value, $frmpro_settings->date_format, 'Y-m-d H:i:s');
         }
     } else {
         if ($field->type != 'tag' && $field->field_options['post_field'] == 'post_category') {
             $value = (array) $value;
             // change text to numeric ids
             if (defined('WP_IMPORTING')) {
                 foreach ($value as $k => $val) {
                     if (empty($val)) {
                         continue;
                     }
                     $term = term_exists($val, $field->field_options['taxonomy']);
                     if ($term) {
                         $value[$k] = is_array($term) ? $term['term_id'] : $term;
                     }
                     unset($k, $val, $term);
                 }
             }
             if (isset($field->field_options['taxonomy']) && $field->field_options['taxonomy'] != 'category') {
                 $new_value = array();
                 foreach ($value as $val) {
                     if ($val == 0) {
                         continue;
                     }
                     $term = get_term($val, $field->field_options['taxonomy']);
                     if (!isset($term->errors)) {
                         $new_value[$val] = $term->name;
                     } else {
                         $new_value[$val] = $val;
                     }
                     unset($term);
                 }
                 if (!isset($_POST['frm_tax_input'])) {
                     $_POST['frm_tax_input'] = array();
                 }
                 if (isset($_POST['frm_tax_input'][$field->field_options['taxonomy']])) {
                     foreach ($new_value as $new_key => $new_name) {
                         $_POST['frm_tax_input'][$field->field_options['taxonomy']][$new_key] = $new_name;
                     }
                 } else {
                     $_POST['frm_tax_input'][$field->field_options['taxonomy']] = $new_value;
                 }
             } else {
                 $_POST['frm_wp_post'][$field->id . '=' . $field->field_options['post_field']] = $value;
             }
         } else {
             if ($field->type == 'tag' && $field->field_options['post_field'] == 'post_category') {
                 $value = trim($value);
                 $value = array_map('trim', explode(',', $value));
                 $tax_type = isset($field->field_options['taxonomy']) && !empty($field->field_options['taxonomy']) ? $field->field_options['taxonomy'] : 'frm_tag';
                 if (!isset($_POST['frm_tax_input'])) {
                     $_POST['frm_tax_input'] = array();
                 }
                 if (is_taxonomy_hierarchical($tax_type)) {
                     //create the term or check to see if it exists
                     $terms = array();
                     foreach ($value as $v) {
                         $term_id = term_exists($v, $tax_type);
                         if (!$term_id) {
                             $term_id = wp_insert_term($v, $tax_type);
                         }
                         if ($term_id && is_array($term_id)) {
                             $term_id = $term_id['term_id'];
                         }
                         if (is_numeric($term_id)) {
                             $terms[$term_id] = $v;
                         }
                         unset($term_id);
                         unset($v);
                     }
                     $value = $terms;
                     unset($terms);
                 }
                 if (!isset($_POST['frm_tax_input'][$tax_type])) {
                     $_POST['frm_tax_input'][$tax_type] = (array) $value;
                 } else {
                     $_POST['frm_tax_input'][$tax_type] += (array) $value;
                 }
             }
         }
     }
     if ($field->field_options['post_field'] != 'post_category') {
         $_POST['frm_wp_post'][$field->id . '=' . $field->field_options['post_field']] = $value;
     }
     if (isset($errors)) {
         return $errors;
     }
 }
Пример #22
0
 public static function &filter_display_value($value, $field, $atts = array())
 {
     $defaults = array('html' => 0, 'type' => $field->type, 'keepjs' => 0);
     $atts = array_merge($defaults, $atts);
     switch ($atts['type']) {
         case 'user_id':
             $value = FrmProFieldsHelper::get_display_name($value);
             break;
         case 'date':
             $value = FrmProFieldsHelper::get_date($value);
             break;
         case 'file':
             $old_value = $value;
             if ($atts['html']) {
                 $value = '<div class="frm_file_container">';
             } else {
                 $value = '';
             }
             foreach ((array) $old_value as $mid) {
                 if ($atts['html']) {
                     $img = FrmProFieldsHelper::get_file_icon($mid);
                     $value .= $img;
                     if ($atts['show_filename'] && $img && preg_match('/wp-includes\\/images\\/(crystal|media)/', $img)) {
                         //prevent two filenames
                         $atts['show_filename'] = $show_filename = false;
                     }
                     unset($img);
                     if ($atts['html'] && $atts['show_filename']) {
                         $value .= '<br/>' . FrmProFieldsHelper::get_file_name($mid) . '<br/>';
                     }
                     if (isset($show_filename)) {
                         //if skipped filename, show it for the next file
                         $atts['show_filename'] = true;
                         unset($show_filename);
                     }
                 } else {
                     if ($mid) {
                         $value .= FrmProFieldsHelper::get_file_name($mid) . $atts['sep'];
                     }
                 }
             }
             $value = rtrim($value, $atts['sep']);
             if ($atts['html']) {
                 $value .= '</div>';
             }
             break;
         case 'data':
             if (!is_numeric($value)) {
                 if (!is_array($value)) {
                     $value = explode($atts['sep'], $value);
                 }
                 if (is_array($value)) {
                     $new_value = '';
                     foreach ($value as $entry_id) {
                         if (!empty($new_value)) {
                             $new_value .= $atts['sep'];
                         }
                         if (is_numeric($entry_id)) {
                             $new_value .= FrmProFieldsHelper::get_data_value($entry_id, $field, $atts);
                         } else {
                             $new_value .= $entry_id;
                         }
                     }
                     $value = $new_value;
                 }
             } else {
                 //replace item id with specified field
                 $new_value = FrmProFieldsHelper::get_data_value($value, $field, $atts);
                 if (FrmProField::is_list_field($field)) {
                     $linked_field = FrmField::getOne($field->field_options['form_select']);
                     if ($linked_field && $linked_field->type == 'file') {
                         $old_value = explode(', ', $new_value);
                         $new_value = '';
                         foreach ($old_value as $v) {
                             $new_value .= '<img src="' . esc_url($v) . '" class="frm_image_from_url" alt="" />';
                             if ($atts['show_filename']) {
                                 $new_value .= '<br/>' . $v;
                             }
                             unset($v);
                         }
                     } else {
                         $new_value = $value;
                     }
                 }
                 $value = $new_value;
             }
             break;
         case 'image':
             $value = FrmProFieldsHelper::get_image_display_value($value, array('html' => true));
             break;
     }
     if (!$atts['keepjs']) {
         $value = FrmAppHelper::recursive_function_map($value, 'wp_kses_post');
     }
     return FrmEntriesController::filter_display_value($value, $field, $atts);
 }
Пример #23
0
selected($where_field, 'item_key');
?>
><?php 
_e('Entry Key', 'formidable');
?>
</option>
        <option value="post_id" <?php 
selected($where_field, 'post_id');
?>
><?php 
_e('Post ID', 'formidable');
?>
</option>
        <?php 
if (is_numeric($form_id)) {
    FrmProFieldsHelper::get_field_options($form_id, $where_field, 'not', "'break','divider','file'");
}
?>
    </select>
    <?php 
_e('is', 'formidable');
?>
    <select id="where_field_is" name="options[where_is][<?php 
echo $where_key;
?>
]" style="width:100px;">
        <option value="=" <?php 
selected($where_is, '=');
?>
><?php 
_e('equal to', 'formidable');
Пример #24
0
selected($where_field, 'item_key');
?>
><?php 
_e('Entry Key', 'formidable');
?>
</option>
		<option value="post_id" <?php 
selected($where_field, 'post_id');
?>
><?php 
_e('Post ID', 'formidable');
?>
</option>
        <?php 
if (is_numeric($form_id)) {
    FrmProFieldsHelper::get_field_options($form_id, $where_field, 'not', array('break', 'end_divider', 'divider', 'file', 'captcha', 'form'), array('inc_sub' => 'include'));
}
?>
        <option value="ip" <?php 
selected($where_field, 'ip');
?>
><?php 
_e('IP', 'formidable');
?>
</option>
    </select>
    <?php 
_e('is', 'formidable');
?>
    <select id="where_field_is_<?php 
echo esc_attr($where_key);
 function get_display_data($display, $content = '', $entry_id = false, $extra_atts = array())
 {
     global $frmpro_display, $frm_entry, $frmpro_settings, $frm_entry_meta, $frm_forms_loaded;
     $frm_forms_loaded[] = true;
     $defaults = array('filter' => false, 'user_id' => '', 'limit' => '', 'page_size' => '', 'order_by' => '', 'order' => '');
     extract(wp_parse_args($extra_atts, $defaults));
     if (FrmProAppHelper::rewriting_on() && $frmpro_settings->permalinks) {
         $this->parse_pretty_entry_url();
     }
     if (is_numeric($display->entry_id) && $display->entry_id > 0 and !$entry_id) {
         $entry_id = $display->entry_id;
     }
     $entry = false;
     $show = 'all';
     if (in_array($display->show_count, array('dynamic', 'calendar', 'one'))) {
         $one_param = isset($_GET['entry']) ? $_GET['entry'] : $entry_id;
         $get_param = isset($_GET[$display->param]) ? $_GET[$display->param] : ($display->show_count == 'one' ? $one_param : $entry_id);
         unset($one_param);
         if ($get_param) {
             $where_entry = array('it.form_id' => $display->form_id);
             if (($display->type == 'id' or $display->show_count == 'one') and is_numeric($get_param)) {
                 $where_entry['it.id'] = $get_param;
             } else {
                 $where_entry['it.item_key'] = $get_param;
             }
             $entry = $frm_entry->getAll($where_entry, '', 1, 0);
             if ($entry) {
                 $entry = reset($entry);
             }
             if ($entry and $entry->post_id) {
                 //redirect to single post page if this entry is a post
                 global $post;
                 if (in_the_loop() and $display->show_count != 'one' and !is_single($entry->post_id) and $post->ID != $entry->post_id) {
                     $this_post = get_post($entry->post_id);
                     if (in_array($this_post->post_status, array('publish', 'private'))) {
                         die('<script type="text/javascript">window.location="' . get_permalink($entry->post_id) . '"</script>');
                     }
                 }
             }
         }
         unset($get_param);
     }
     if ($entry and in_array($display->show_count, array('dynamic', 'calendar'))) {
         $new_content = stripslashes($display->dyncontent);
         $show = 'one';
     } else {
         $new_content = stripslashes($display->content);
     }
     $show = ($display->show_count == 'one' or $entry_id and is_numeric($entry_id)) ? 'one' : $show;
     $shortcodes = FrmProDisplaysHelper::get_shortcodes($new_content, $display->form_id);
     $pagination = '';
     if ($entry and $entry->form_id == $display->form_id) {
         $display_content = FrmProFieldsHelper::replace_shortcodes($new_content, $entry, $shortcodes, $display, $show);
     } else {
         global $frmdb, $wpdb;
         $options = maybe_unserialize($display->options);
         $empty_msg = '<div class="frm_no_entries">' . (isset($options['empty_msg']) ? stripslashes($options['empty_msg']) : '') . '</div>';
         $display_content = '';
         if ($show == 'all') {
             $display_content .= isset($options['before_content']) ? stripslashes($options['before_content']) : '';
         }
         $display_content = apply_filters('frm_before_display_content', $display_content, $display, $show);
         $where = 'it.form_id=' . $display->form_id;
         $form_posts = $frmdb->get_records($frmdb->entries, array('form_id' => $display->form_id, 'post_id >' => 1), '', '', 'id,post_id');
         $entry_ids = $frmdb->get_col($frmdb->entries, array('form_id' => $display->form_id), 'id');
         $after_where = false;
         if ($user_id and !empty($user_id)) {
             $user_id = FrmProAppHelper::get_user_id_param($user_id);
             $uid_used = false;
         }
         if (isset($options['where']) and !empty($options['where'])) {
             $options['where'] = apply_filters('frm_custom_where_opt', $options['where'], array('display' => $display, 'entry' => $entry));
             $continue = false;
             foreach ($options['where'] as $where_key => $where_opt) {
                 $where_val = isset($options['where_val'][$where_key]) ? $options['where_val'][$where_key] : '';
                 if (preg_match("/\\[(get|get-(.?))\\b(.*?)(?:(\\/))?\\]/s", $where_val)) {
                     $where_val = FrmProFieldsHelper::get_default_value($where_val, false, true, true);
                     //if this param doesn't exist, then don't include it
                     if ($where_val == '') {
                         if (!$after_where) {
                             $continue = true;
                         }
                         continue;
                     }
                 } else {
                     $where_val = FrmProFieldsHelper::get_default_value($where_val, false, true, true);
                 }
                 $continue = false;
                 if ($where_val == 'current_user') {
                     if ($user_id and is_numeric($user_id)) {
                         $where_val = $user_id;
                         $uid_used = true;
                     } else {
                         global $user_ID;
                         $where_val = $user_ID;
                     }
                 }
                 $where_val = do_shortcode($where_val);
                 if (is_array($where_val) and !empty($where_val)) {
                     $new_where = '(';
                     if (strpos($options['where_is'][$where_key], 'LIKE') !== false) {
                         foreach ($where_val as $w) {
                             if ($new_where != '(') {
                                 $new_where .= ',';
                             }
                             $new_where .= "'%" . esc_sql(like_escape($w)) . "%'";
                             unset($w);
                         }
                     } else {
                         foreach ($where_val as $w) {
                             if ($new_where != '(') {
                                 $new_where .= ',';
                             }
                             $new_where .= "'" . esc_sql($w) . "'";
                             unset($w);
                         }
                     }
                     $new_where .= ')';
                     $where_val = $new_where;
                     unset($new_where);
                     if (strpos($options['where_is'][$where_key], '!') === false and strpos($options['where_is'][$where_key], 'not') === false) {
                         $options['where_is'][$where_key] = ' in ';
                     } else {
                         $options['where_is'][$where_key] = ' not in ';
                     }
                 }
                 if (is_numeric($where_opt)) {
                     $entry_ids = FrmProAppHelper::filter_where($entry_ids, array('where_opt' => $where_opt, 'where_is' => $options['where_is'][$where_key], 'where_val' => $where_val, 'form_id' => $display->form_id, 'form_posts' => $form_posts, 'after_where' => $after_where));
                     $after_where = true;
                     $continue = false;
                     if (empty($entry_ids)) {
                         break;
                     }
                 } else {
                     if ($where_opt == 'created_at') {
                         if ($where_val == 'NOW') {
                             $where_val = current_time('mysql', 1);
                         }
                         $where_val = date('Y-m-d H:i:s', strtotime($where_val));
                         $where .= " and it.created_at " . $options['where_is'][$where_key];
                         if (strpos($options['where_is'][$where_key], 'in')) {
                             $where .= " {$where_val}";
                         } else {
                             $where .= " '" . esc_sql($where_val) . "'";
                         }
                         $continue = true;
                     } else {
                         if ($where_opt == 'id' or $where_opt == 'item_key') {
                             $where .= " and it.{$where_opt} " . $options['where_is'][$where_key];
                             if (strpos($options['where_is'][$where_key], 'in')) {
                                 $where .= " {$where_val}";
                             } else {
                                 $where .= " '" . esc_sql($where_val) . "'";
                             }
                             $continue = true;
                         }
                     }
                 }
             }
             if (!$continue and empty($entry_ids)) {
                 return $content . ' ' . $empty_msg;
             }
         }
         if ($user_id and is_numeric($user_id) and !$uid_used) {
             $where .= " AND it.user_id=" . (int) $user_id;
         }
         $s = FrmAppHelper::get_param('frm_search', false);
         if ($s) {
             $new_ids = FrmProEntriesHelper::get_search_ids($s, $display->form_id);
             if ($after_where and isset($entry_ids) and !empty($entry_ids)) {
                 $entry_ids = array_intersect($new_ids, $entry_ids);
             } else {
                 $entry_ids = $new_ids;
             }
             if (empty($entry_ids)) {
                 return $content . ' ' . $empty_msg;
             }
         }
         if (isset($entry_ids) and !empty($entry_ids)) {
             $where .= ' and it.id in (' . implode(',', $entry_ids) . ')';
         }
         if ($entry_id) {
             $where .= " and it.id in ({$entry_id})";
         }
         if ($show == 'one') {
             $limit = ' LIMIT 1';
         } else {
             if (isset($_GET['frm_cat']) and isset($_GET['frm_cat_id'])) {
                 //Get fields with specified field value 'frm_cat' = field key/id, 'frm_cat_id' = order position of selected option
                 global $frm_field;
                 if ($cat_field = $frm_field->getOne($_GET['frm_cat'])) {
                     $categories = maybe_unserialize($cat_field->options);
                     if (isset($categories[$_GET['frm_cat_id']])) {
                         $cat_entry_ids = $frm_entry_meta->getEntryIds("meta_value='" . $categories[$_GET['frm_cat_id']] . "' and fi.field_key='{$_GET['frm_cat']}'");
                     }
                     if ($cat_entry_ids) {
                         $where .= " and it.id in (" . implode(',', $cat_entry_ids) . ")";
                     }
                 }
             }
         }
         if (is_array($options)) {
             if (!empty($limit) and is_numeric($limit)) {
                 $options['limit'] = (int) $limit;
             }
             if (is_numeric($options['limit'])) {
                 $num_limit = (int) $options['limit'];
                 $limit = ' LIMIT ' . $options['limit'];
             }
             if (!empty($order_by)) {
                 $options['order_by'] = $order_by;
             }
             if (!empty($order)) {
                 $options['order'] = $order;
             }
             if (isset($options['order_by']) && $options['order_by'] != '') {
                 /*if( $wpdb->has_cap( 'collation' ) ){
                       $charset_collate = '';
                       if( !empty($wpdb->charset) )
                           $charset_collate .= "DEFAULT CHARACTER SET $wpdb->charset";
                       if( !empty($wpdb->collate) )
                           $charset_collate .= " COLLATE $wpdb->collate";
                   }*/
                 $order = isset($options['order']) ? ' ' . $options['order'] : '';
                 if ($options['order_by'] == 'rand') {
                     $order_by = ' RAND()';
                 } else {
                     if (is_numeric($options['order_by'])) {
                         global $frm_entry_meta, $frm_field;
                         $order_field = $frm_field->getOne($options['order_by']);
                         $order_field->field_options = maybe_unserialize($order_field->field_options);
                         $meta_order = $order_field->type == 'number' ? ' LENGTH(meta_value),' : '';
                         if (isset($order_field->field_options['post_field']) and $order_field->field_options['post_field']) {
                             $posts = $form_posts;
                             //$frmdb->get_records($frmdb->entries, array('form_id' => $display->form_id, 'post_id >' => 1), '', '', 'id, post_id');
                             $linked_posts = array();
                             foreach ($posts as $post_meta) {
                                 $linked_posts[$post_meta->post_id] = $post_meta->id;
                             }
                             if ($order_field->field_options['post_field'] == 'post_custom') {
                                 $ordered_ids = $wpdb->get_col("SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key='" . $order_field->field_options['custom_field'] . "' AND post_id in (" . implode(',', array_keys($linked_posts)) . ") ORDER BY meta_value" . $order);
                                 $metas = array();
                                 foreach ($ordered_ids as $ordered_id) {
                                     $metas[] = array('item_id' => $linked_posts[$ordered_id]);
                                 }
                             } else {
                                 if ($order_field->field_options['post_field'] != 'post_category') {
                                     $ordered_ids = $wpdb->get_col("SELECT ID FROM {$wpdb->posts} WHERE ID in (" . implode(',', array_keys($linked_posts)) . ") ORDER BY " . $order_field->field_options['post_field'] . ' ' . $order);
                                     $metas = array();
                                     foreach ($ordered_ids as $ordered_id) {
                                         $metas[] = array('item_id' => $linked_posts[$ordered_id]);
                                     }
                                 }
                             }
                         } else {
                             if ($order_field->type == 'number') {
                                 $query = "SELECT it.*, meta_value +0 as odr FROM {$frmdb->entry_metas} it LEFT OUTER JOIN {$frmdb->fields} fi ON it.field_id=fi.id WHERE fi.form_id={$display->form_id} and fi.id={$options['order_by']}";
                                 if (isset($entry_ids) and !empty($entry_ids)) {
                                     $query .= " AND it.item_id in (" . implode(',', $entry_ids) . ")";
                                 }
                                 $query .= " ORDER BY odr {$order} {$limit}";
                                 if ($limit == ' LIMIT 1') {
                                     $metas = $wpdb->get_row($query);
                                 } else {
                                     $metas = $wpdb->get_results($query);
                                 }
                             } else {
                                 $metas = $frm_entry_meta->getAll('fi.form_id=' . $display->form_id . ' and fi.id=' . $options['order_by'], ' ORDER BY ' . $meta_order . ' meta_value' . $order);
                                 //TODO: add previous $where and $limit
                             }
                         }
                         if (isset($metas) and is_array($metas) and !empty($metas)) {
                             if ($order_field->type == 'time' and (!isset($order_field->field_options['clock']) or $order_field->field_options['clock'] == 12)) {
                                 $new_order = array();
                                 foreach ($metas as $key => $meta) {
                                     $parts = str_replace(array(' PM', ' AM'), '', $meta->meta_value);
                                     $parts = explode(':', $parts);
                                     if (is_array($parts)) {
                                         if (preg_match('/PM/', $meta->meta_value) and (int) $parts[0] != 12 or (int) $parts[0] == 12 and preg_match('/AM/', $meta->meta_value)) {
                                             $parts[0] = (int) $parts[0] + 12;
                                         }
                                     }
                                     $new_order[$key] = (int) $parts[0] . $parts[1];
                                     unset($key);
                                     unset($meta);
                                 }
                                 //array with sorted times
                                 asort($new_order);
                                 $final_order = array();
                                 foreach ($new_order as $key => $time) {
                                     $final_order[] = $metas[$key];
                                     unset($key);
                                     unset($time);
                                 }
                                 $metas = $final_order;
                                 unset($final_order);
                             }
                             $rev_order = ($order == 'DESC' or $order == '') ? ' ASC' : ' DESC';
                             foreach ($metas as $meta) {
                                 $meta = (array) $meta;
                                 $order_by .= 'it.id=' . $meta['item_id'] . $rev_order . ', ';
                             }
                             $order_by = rtrim($order_by, ', ');
                         } else {
                             $order_by .= 'it.created_at' . $order;
                         }
                     } else {
                         $order_by = 'it.' . $options['order_by'] . $order;
                     }
                 }
                 $order_by = ' ORDER BY ' . $order_by;
             }
         }
         if (!empty($page_size) and is_numeric($page_size)) {
             $options['page_size'] = (int) $page_size;
         }
         if (isset($options['page_size']) && is_numeric($options['page_size'])) {
             global $frm_app_helper;
             $current_page = FrmAppHelper::get_param('frm-page', 1);
             $record_where = $where == "it.form_id={$display->form_id}" ? $display->form_id : $where;
             $record_count = $frm_entry->getRecordCount($record_where);
             if (isset($num_limit) and $record_count > (int) $num_limit) {
                 $record_count = (int) $num_limit;
             }
             $page_count = $frm_entry->getPageCount($options['page_size'], $record_count);
             $entries = $frm_entry->getPage($current_page, $options['page_size'], $where, $order_by);
             $page_last_record = $frm_app_helper->getLastRecordNum($record_count, $current_page, $options['page_size']);
             $page_first_record = $frm_app_helper->getFirstRecordNum($record_count, $current_page, $options['page_size']);
             if ($page_count > 1) {
                 $pagination = FrmProDisplaysController::get_pagination_file(FRMPRO_VIEWS_PATH . '/displays/pagination.php', compact('current_page', 'record_count', 'page_count', 'page_last_record', 'page_first_record'));
             }
         } else {
             $entries = $frm_entry->getAll($where, $order_by, $limit, true, false);
         }
         $filtered_content = apply_filters('frm_display_entries_content', $new_content, $entries, $shortcodes, $display, $show);
         if ($filtered_content != $new_content) {
             $display_content .= $filtered_content;
         } else {
             $odd = 'odd';
             $count = 0;
             if (!empty($entries)) {
                 foreach ($entries as $entry) {
                     $count++;
                     //TODO: use the count with conditionals
                     $display_content .= apply_filters('frm_display_entry_content', $new_content, $entry, $shortcodes, $display, $show, $odd);
                     $odd = $odd == 'odd' ? 'even' : 'odd';
                     unset($entry);
                 }
                 unset($count);
             } else {
                 $display_content .= $empty_msg;
             }
         }
         if ($show == 'all') {
             $display_content .= isset($options['after_content']) ? stripslashes($options['after_content']) : '';
         }
     }
     $display_content .= apply_filters('frm_after_display_content', $pagination, $display, $show);
     if ($display->insert_loc == 'after') {
         $content .= $display_content;
     } else {
         if ($display->insert_loc == 'before') {
             $content = $display_content . $content;
         } else {
             if ($filter) {
                 $display_content = apply_filters('the_content', $display_content);
             }
             $content = $display_content;
         }
     }
     return $content;
 }
Пример #26
0
 function validate($errors, $field)
 {
     if ($field->type == 'user_id') {
         // make sure we have a user ID
         if (!is_numeric($_POST['item_meta'][$field->id])) {
             $_POST['item_meta'][$field->id] = FrmProAppHelper::get_user_id_param($_POST['item_meta'][$field->id]);
         }
         //add user id to post variables to be saved with entry
         $_POST['frm_user_id'] = $_POST['item_meta'][$field->id];
     } else {
         if ($field->type == 'time' and is_array($_POST['item_meta'][$field->id])) {
             $_POST['item_meta'][$field->id] = $value = $_POST['item_meta'][$field->id]['H'] . ':' . $_POST['item_meta'][$field->id]['m'] . (isset($_POST['item_meta'][$field->id]['A']) ? ' ' . $_POST['item_meta'][$field->id]['A'] : '');
         }
     }
     // don't validate if going backwards
     if (FrmProFormsHelper::going_to_prev($field->form_id)) {
         return array();
     }
     // clear any existing errors if draft
     if (FrmProFormsHelper::saving_draft($field->form_id) && isset($errors['field' . $field->id])) {
         unset($errors['field' . $field->id]);
     }
     //if the field is a file upload, check for a file
     if ($field->type == 'file' && isset($_FILES['file' . $field->id]) && !empty($_FILES['file' . $field->id]['name'])) {
         $filled = true;
         if (is_array($_FILES['file' . $field->id]['name'])) {
             $filled = false;
             foreach ($_FILES['file' . $field->id]['name'] as $n) {
                 if (!empty($n)) {
                     $filled = true;
                 }
             }
         }
         if ($filled) {
             if (isset($errors['field' . $field->id])) {
                 unset($errors['field' . $field->id]);
             }
             if (isset($field->field_options['restrict']) && $field->field_options['restrict'] && isset($field->field_options['ftypes']) && !empty($field->field_options['ftypes'])) {
                 $mimes = $field->field_options['ftypes'];
             } else {
                 $mimes = null;
             }
             //check allowed mime types for this field
             if (is_array($_FILES['file' . $field->id]['name'])) {
                 foreach ($_FILES['file' . $field->id]['name'] as $name) {
                     if (empty($name)) {
                         continue;
                     }
                     $file_type = wp_check_filetype($name, $mimes);
                     unset($name);
                     if (!$file_type['ext']) {
                         break;
                     }
                 }
             } else {
                 $file_type = wp_check_filetype($_FILES['file' . $field->id]['name'], $mimes);
             }
             if (isset($file_type) && !$file_type['ext']) {
                 $errors['field' . $field->id] = $field->field_options['invalid'] == __('This field is invalid', 'formidable') || $field->field_options['invalid'] == '' || $field->field_options['invalid'] == $field->name . ' ' . __('is invalid', 'formidable') ? __('Sorry, this file type is not permitted for security reasons.', 'formidable') : $field->field_options['invalid'];
             }
             unset($file_type);
         }
         unset($filled);
     }
     // if saving draft, only check file type since it won't be checked later
     if (FrmProFormsHelper::saving_draft($field->form_id)) {
         return $errors;
     }
     if (in_array($field->type, array('break', 'html', 'divider'))) {
         $hidden = FrmProFieldsHelper::is_field_hidden($field, stripslashes_deep($_POST));
         global $frm_hidden_break, $frm_hidden_divider;
         if ($field->type == 'break') {
             $frm_hidden_break = array('field_order' => $field->field_order, 'hidden' => $hidden);
         } else {
             if ($field->type == 'divider') {
                 $frm_hidden_divider = array('field_order' => $field->field_order, 'hidden' => $hidden);
             }
         }
         if (isset($errors['field' . $field->id])) {
             unset($errors['field' . $field->id]);
         }
     }
     $value = $_POST['item_meta'][$field->id];
     if (($field->type != 'tag' and $value == 0 or $field->type == 'tag' and $value == '') and isset($field->field_options['post_field']) and $field->field_options['post_field'] == 'post_category' and $field->required == '1') {
         global $frm_settings;
         $errors['field' . $field->id] = (!isset($field->field_options['blank']) or $field->field_options['blank'] == '' or $field->field_options['blank'] == 'Untitled cannot be blank') ? $frm_settings->blank_msg : $field->field_options['blank'];
     }
     //Don't require fields hidden with shortcode fields="25,26,27"
     global $frm_vars;
     if (isset($frm_vars['show_fields']) and !empty($frm_vars['show_fields']) and is_array($frm_vars['show_fields']) and $field->required == '1' and isset($errors['field' . $field->id]) and !in_array($field->id, $frm_vars['show_fields']) and !in_array($field->field_key, $frm_vars['show_fields'])) {
         unset($errors['field' . $field->id]);
         $_POST['item_meta'][$field->id] = $value = '';
     }
     //Don't require a conditionally hidden field
     if (isset($field->field_options['hide_field']) and !empty($field->field_options['hide_field'])) {
         if (FrmProFieldsHelper::is_field_hidden($field, stripslashes_deep($_POST))) {
             if (isset($errors['field' . $field->id])) {
                 unset($errors['field' . $field->id]);
             }
             $_POST['item_meta'][$field->id] = $value = '';
         }
     }
     //Don't require a field hidden in a conditional page or section heading
     if (isset($errors['field' . $field->id]) or $_POST['item_meta'][$field->id] != '') {
         global $frm_hidden_break, $frm_hidden_divider;
         if ($frm_hidden_break and $frm_hidden_break['hidden'] or $frm_hidden_divider and $frm_hidden_divider['hidden'] and (!$frm_hidden_break or $frm_hidden_break['field_order'] < $frm_hidden_divider['field_order'])) {
             if (isset($errors['field' . $field->id])) {
                 unset($errors['field' . $field->id]);
             }
             $_POST['item_meta'][$field->id] = $value = '';
         }
     }
     //make sure the [auto_id] is still unique
     if (!empty($field->default_value) and !is_array($field->default_value) and !empty($value) and is_numeric($value) and strpos($field->default_value, '[auto_id') !== false) {
         //make sure we are not editing
         if (isset($_POST) and !isset($_POST['id']) or !is_numeric($_POST['id'])) {
             $_POST['item_meta'][$field->id] = $value = FrmProFieldsHelper::get_default_value($field->default_value, $field);
         }
     }
     //check uniqueness
     if ($value and !empty($value) and isset($field->field_options['unique']) and $field->field_options['unique']) {
         $entry_id = (isset($_POST) and isset($_POST['id'])) ? $_POST['id'] : false;
         if ($field->type == 'time') {
             //TODO: add server-side validation for unique date-time
         } else {
             if ($field->type == 'date') {
                 global $frmpro_settings;
                 $old_value = $value;
                 if (!preg_match('/^\\d{4}-\\d{2}-\\d{2}$/', trim($value))) {
                     $value = FrmProAppHelper::convert_date($value, $frmpro_settings->date_format, 'Y-m-d');
                 }
                 if (FrmProEntryMetaHelper::value_exists($field->id, $value, $entry_id)) {
                     $errors['field' . $field->id] = FrmProFieldsHelper::get_error_msg($field, 'unique_msg');
                 }
                 $value = $old_value;
             } else {
                 if (FrmProEntryMetaHelper::value_exists($field->id, $value, $entry_id)) {
                     $errors['field' . $field->id] = FrmProFieldsHelper::get_error_msg($field, 'unique_msg');
                 }
             }
         }
         unset($entry_id);
     }
     // validate number settings
     if ('number' == $field->type && $value != '') {
         global $frm_settings;
         // only check if options are available in settings
         if ($frm_settings->use_html && isset($field->field_options['minnum']) && isset($field->field_options['maxnum'])) {
             //minnum maxnum
             if ((double) $value < $field->field_options['minnum']) {
                 $errors['field' . $field->id] = __('Please select a higher number', 'formidable');
             } else {
                 if ((double) $value > $field->field_options['maxnum']) {
                     $errors['field' . $field->id] = __('Please select a lower number', 'formidable');
                 }
             }
         }
     }
     if (!empty($value) and ($field->type == 'website' or $field->type == 'url' or $field->type == 'image')) {
         if (trim($value) == 'http://') {
             $_POST['item_meta'][$field->id] = $value = '';
         } else {
             $value = esc_url_raw($value);
             $_POST['item_meta'][$field->id] = $value = preg_match('/^(https?|ftps?|mailto|news|feed|telnet):/is', $value) ? $value : 'http://' . $value;
         }
     }
     $errors = FrmProEntryMetaHelper::set_post_fields($field, $value, $errors);
     if (!FrmProFieldsHelper::is_field_visible_to_user($field)) {
         //don't validate admin only fields that can't be seen
         unset($errors['field' . $field->id]);
         return $errors;
     }
     if (false and isset($field->field_options['use_calc']) and !empty($field->field_options['use_calc']) and !empty($field->field_options['calc'])) {
         $field->field_options['calc'] = trim($field->field_options['calc']);
         preg_match_all("/\\[(.*?)\\]/s", $field->field_options['calc'], $calc_matches, PREG_PATTERN_ORDER);
         if (isset($calc_matches[1])) {
             foreach ($calc_matches[1] as $c) {
                 if (is_numeric($c)) {
                     $c_id = $c;
                 } else {
                     global $frm_field;
                     $c_field = $frm_field->getOne($c);
                     if (!$c_field) {
                         $field->field_options['calc'] = str_replace('[' . $c . ']', 0, $field->field_options['calc']);
                         continue;
                     }
                     $c_id = $c_field->id;
                     unset($c_field);
                 }
                 $c_val = trim($_POST['item_meta'][$c_id]);
                 if (!is_numeric($c_val)) {
                     preg_match_all('/[0-9,]*\\.?[0-9]+/', $c_val, $c_matches);
                     $c_val = $c_matches ? end($c_matches[0]) : 0;
                     unset($c_matches);
                 }
                 if ($c_val == '') {
                     $c_val = 0;
                 }
                 $field->field_options['calc'] = str_replace('[' . $c . ']', $c_val, $field->field_options['calc']);
                 unset($c);
                 unset($c_id);
             }
             include FrmAppHelper::plugin_path() . '/pro/classes/helpers/FrmProMathHelper.php';
             $m = new EvalMath();
             if (strpos($field->field_options['calc'], ').toFixed(')) {
                 $field->field_options['calc'] = str_replace(').toFixed(2', '', $field->field_options['calc']);
                 $round = 2;
             }
             $result = $m->evaluate(str_replace('Math.', '', '(' . $field->field_options['calc'] . ')'));
             if (isset($round) and $round) {
                 $result = sprintf('%.' . $round . 'f', $result);
             }
             unset($m);
             $_POST['item_meta'][$field->id] = $value = $result;
             unset($result);
         }
         unset($calc_matches);
     }
     //Don't validate the format if field is blank
     if ($value == '' or is_array($value)) {
         return $errors;
     }
     $value = trim($value);
     //validate the format
     if ($field->type == 'number' and !is_numeric($value) or $field->type == 'email' and !is_email($value) or ($field->type == 'website' or $field->type == 'url' or $field->type == 'image') and !preg_match('/^http(s)?:\\/\\/([\\da-z\\.-]+)\\.([\\da-z\\.-]+)/i', $value)) {
         $errors['field' . $field->id] = FrmProFieldsHelper::get_error_msg($field, 'invalid');
     }
     if ($field->type == 'phone') {
         $pattern = (isset($field->field_options['format']) and !empty($field->field_options['format'])) ? $field->field_options['format'] : '^((\\+\\d{1,3}(-|.| )?\\(?\\d\\)?(-| |.)?\\d{1,5})|(\\(?\\d{2,6}\\)?))(-|.| )?(\\d{3,4})(-|.| )?(\\d{4})(( x| ext)\\d{1,5}){0,1}$';
         $pattern = apply_filters('frm_phone_pattern', $pattern, $field);
         //check if format is already a regular expression
         if (strpos($pattern, '^') !== 0) {
             //if not, create a regular expression
             $pattern = preg_replace('/\\d/', '\\d', preg_quote($pattern));
             $pattern = '/^' . $pattern . '$/';
         } else {
             $pattern = '/' . $pattern . '/';
         }
         if (!preg_match($pattern, $value)) {
             $errors['field' . $field->id] = FrmProFieldsHelper::get_error_msg($field, 'invalid');
         }
         unset($pattern);
     }
     if ($field->type == 'date') {
         if (!preg_match('/^\\d{4}-\\d{2}-\\d{2}$/', $value)) {
             global $frmpro_settings;
             $formated_date = FrmProAppHelper::convert_date($value, $frmpro_settings->date_format, 'Y-m-d');
             //check format before converting
             if ($value != date($frmpro_settings->date_format, strtotime($formated_date))) {
                 $errors['field' . $field->id] = FrmProFieldsHelper::get_error_msg($field, 'invalid');
             }
             $value = $formated_date;
             unset($formated_date);
         }
         $date = explode('-', $value);
         if (count($date) != 3 or !checkdate((int) $date[1], (int) $date[2], (int) $date[0])) {
             $errors['field' . $field->id] = FrmProFieldsHelper::get_error_msg($field, 'invalid');
         }
     }
     return $errors;
 }
Пример #27
0
 public static function get_search_ids($s, $form_id, $args = array())
 {
     global $wpdb;
     if (empty($s)) {
         return false;
     }
     preg_match_all('/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $s, $matches);
     $search_terms = array_map('trim', $matches[0]);
     $spaces = '';
     $e_ids = $p_search = array();
     $search = array('or' => 1);
     $data_field = FrmProFormsHelper::has_field('data', $form_id, false);
     foreach ((array) $search_terms as $term) {
         $p_search[] = array($spaces . $wpdb->posts . '.post_title like' => $term, $spaces . $wpdb->posts . '.post_content like' => $term, 'or' => 1);
         $search[$spaces . 'meta_value like'] = $term;
         $spaces .= ' ';
         // add a space to keep the array keys unique
         if (is_numeric($term)) {
             $e_ids[] = (int) $term;
         }
         if ($data_field) {
             $df_form_ids = array();
             //search the joined entry too
             foreach ((array) $data_field as $df) {
                 FrmProFieldsHelper::get_subform_ids($df_form_ids, $df);
                 unset($df);
             }
             $data_form_ids = FrmDb::get_col($wpdb->prefix . 'frm_fields', array('id' => $df_form_ids), 'form_id');
             unset($df_form_ids);
             if ($data_form_ids) {
                 $data_entry_ids = FrmEntryMeta::getEntryIds(array('fi.form_id' => $data_form_ids, 'meta_value like' => $term));
                 if ($data_entry_ids) {
                     if (!isset($search['meta_value'])) {
                         $search['meta_value'] = array();
                     }
                     $search['meta_value'] = array_merge($search['meta_value'], $data_entry_ids);
                 }
             }
             unset($data_form_ids);
         }
     }
     $matching_posts = FrmDb::get_col($wpdb->posts, $p_search, 'ID');
     $p_ids = array($search, 'or' => 1);
     if ($matching_posts) {
         $post_ids = FrmDb::get_col($wpdb->prefix . 'frm_items', array('post_id' => $matching_posts, 'form_id' => (int) $form_id));
         if ($post_ids) {
             $p_ids['item_id'] = $post_ids;
         }
     }
     if (!empty($e_ids)) {
         $p_ids['item_id'] = $e_ids;
     }
     $query = array('fi.form_id' => $form_id);
     $query[] = $p_ids;
     return FrmEntryMeta::getEntryIds($query, '', '', true, $args);
 }
Пример #28
0
 function get_display_value($replace_with, $field, $atts = array())
 {
     $sep = isset($atts['sep']) ? $atts['sep'] : ', ';
     if ($field->type == 'user_id') {
         $user_info = isset($atts['show']) ? $atts['show'] : 'display_name';
         $replace_with = FrmProFieldsHelper::get_display_name($replace_with, $user_info, $atts);
         if (is_array($replace_with)) {
             $new_val = '';
             foreach ($replace_with as $key => $val) {
                 if (!empty($new_val)) {
                     $new_val .= ', ';
                 }
                 $new_val .= $key . '. ' . $val;
             }
             $replace_with = $new_val;
         }
     } else {
         if ($field->type == 'date') {
             if (isset($atts['time_ago'])) {
                 $atts['format'] = 'Y-m-d H:i:s';
             }
             if (!isset($atts['format'])) {
                 $atts['format'] = false;
             }
             $replace_with = FrmProFieldsHelper::get_date($replace_with, $atts['format']);
             if (isset($atts['time_ago'])) {
                 $replace_with = FrmProAppHelper::human_time_diff(strtotime($replace_with), strtotime(date_i18n('Y-m-d')));
             }
         } else {
             if (is_numeric($replace_with) and $field->type == 'file') {
                 //size options are thumbnail, medium, large, or full
                 $size = isset($atts['size']) ? $atts['size'] : 'thumbnail';
                 if ($size != 'id') {
                     $replace_with = FrmProFieldsHelper::get_media_from_id($replace_with, $size);
                 }
             } else {
                 if ($field->type == 'data') {
                     //and (is_numeric($replace_with) or is_array($replace_with))
                     $field->field_options = maybe_unserialize($field->field_options);
                     if (isset($field->field_options['form_select']) and $field->field_options['form_select'] == 'taxonomy') {
                         return $replace_with;
                     }
                     $replace_with = explode($sep, $replace_with);
                     if (isset($atts['show'])) {
                         if (in_array($atts['show'], array('key', 'created-at', 'created_at', 'updated-at', 'updated_at', 'post_id'))) {
                             global $frm_entry;
                             if (is_array($replace_with)) {
                                 $linked_ids = $replace_with;
                                 $replace_with = '';
                                 foreach ($linked_ids as $linked_id) {
                                     $linked_entry = FrmEntry::getOne($linked_id);
                                     if (!empty($replace_with)) {
                                         $replace_with .= $sep;
                                     }
                                     if ($atts['show'] == 'created-at') {
                                         $replace_with .= $linked_entry->created_at;
                                     } else {
                                         if ($atts['show'] == 'updated-at') {
                                             $replace_with .= $linked_entry->updated_at;
                                         } else {
                                             if ($atts['show'] == 'key') {
                                                 $replace_with .= $linked_entry->item_key;
                                             } else {
                                                 $replace_with .= isset($linked_entry->{$atts['show']}) ? $linked_entry->{$atts['show']} : $linked_entry->item_key;
                                             }
                                         }
                                     }
                                 }
                             } else {
                                 $linked_entry = FrmEntry::getOne($replace_with);
                                 if ($atts['show'] == 'created-at') {
                                     $replace_with = $linked_entry->created_at;
                                 } else {
                                     if ($atts['show'] == 'updated-at') {
                                         $replace_with = $linked_entry->updated_at;
                                     } else {
                                         if ($atts['show'] == 'key') {
                                             $replace_with = $linked_entry->item_key;
                                         } else {
                                             $replace_with = isset($linked_entry->{$atts['show']}) ? $linked_entry->{$atts['show']} : $linked_entry->item_key;
                                         }
                                     }
                                 }
                             }
                         } else {
                             if ($atts['show'] == 'id') {
                                 if (is_array($replace_with)) {
                                     $replace_with = implode($sep, $replace_with);
                                 }
                                 //just keep the value since it's already the id
                             } else {
                                 if (is_array($replace_with)) {
                                     $linked_ids = $replace_with;
                                     $replace_with = array();
                                     foreach ($linked_ids as $linked_id) {
                                         $new_val = FrmProFieldsHelper::get_data_value($linked_id, $field, $atts);
                                         if ($linked_id != $new_val) {
                                             $replace_with[] = $new_val;
                                         }
                                         unset($new_val);
                                     }
                                     $replace_with = implode($sep, $replace_with);
                                 } else {
                                     $replace_with = FrmProFieldsHelper::get_data_value($replace_with, $field, $atts);
                                 }
                             }
                         }
                     } else {
                         if (is_array($replace_with)) {
                             $linked_ids = $replace_with;
                             $replace_with = array();
                             foreach ($linked_ids as $linked_id) {
                                 $new_val = FrmProFieldsHelper::get_data_value($linked_id, $field, $atts);
                                 if ($linked_id != $new_val) {
                                     $replace_with[] = $new_val;
                                 }
                                 unset($new_val);
                             }
                             $replace_with = implode($sep, $replace_with);
                         } else {
                             $replace_with = FrmProFieldsHelper::get_data_value($replace_with, $field, $atts);
                         }
                     }
                 } else {
                     if ($field->type == 'textarea') {
                         $autop = isset($atts['wpautop']) ? $atts['wpautop'] : true;
                         if (apply_filters('frm_use_wpautop', $autop)) {
                             $replace_with = wpautop($replace_with);
                         }
                         unset($autop);
                     } else {
                         if ($field->type == 'number') {
                             if (!isset($atts['decimal'])) {
                                 $num = explode('.', $replace_with);
                                 $atts['decimal'] = isset($num[1]) ? strlen($num[1]) : 0;
                             }
                             if (!isset($atts['dec_point'])) {
                                 $atts['dec_point'] = '.';
                             }
                             if (!isset($atts['thousands_sep'])) {
                                 $atts['thousands_sep'] = '';
                             }
                             $replace_with = number_format($replace_with, $atts['decimal'], $atts['dec_point'], $atts['thousands_sep']);
                         }
                     }
                 }
             }
         }
     }
     $replace_with = stripslashes_deep($replace_with);
     return $replace_with;
 }
Пример #29
0
][exclude_cat]',<?php 
        echo $i;
        ?>
)" /> <span class="howto" style="float:none;"><?php 
        printf(__('Check All Level %d', 'formidable'), $i);
        ?>
</span></label>
            <?php 
    }
    ?>
            </div>
            <?php 
    if (!empty($selected_type) && $selected_type != 'data') {
        ?>
            <p class="howto check_lev1_label frm_hidden"><?php 
        _e('NOTE: if the parent is excluded, child categories will be automatically excluded.', 'formidable');
        ?>
</p>
            <?php 
    }
    FrmProFieldsHelper::get_child_checkboxes(array('field' => array('post_field' => 'post_category', 'form_id' => $values['id'], 'field_options' => array('taxonomy' => $field_vars['meta_name']), 'type' => 'checkbox'), 'field_name' => $action_control->get_field_name('post_category') . '[' . $tax_meta . '][exclude_cat]', 'value' => isset($field_vars['exclude_cat']) ? $field_vars['exclude_cat'] : 0, 'exclude' => 'no', 'hide_id' => true, 'tax_num' => $tax_meta));
    ?>
        </div>
        </div>
    </div>
<?php 
    unset($selected_type);
}
unset($tax_meta);
?>
</div>
Пример #30
0
printf(__('Select a field from your form that contains values like 1 week, 2 weeks, 1 year, etc. This will set the repeat period for each event.', 'formidable'), FrmAppHelper::site_url());
?>
" ></span> </label>
<select id="repeat_event_field_id" name="options[repeat_event_field_id]">
    <option value=""><?php 
_e('No repeating events', 'formidable');
?>
</option>
    <?php 
if (is_numeric($post->frm_form_id) && !empty($post->frm_form_id)) {
    FrmProFieldsHelper::get_field_options($post->frm_form_id, $post->frm_repeat_event_field_id, '', "'radio', 'select'");
}
?>
</select>
<br/>

<label class="frm_left_label"><?php 
_e('End Repeat', 'formidable');
?>
</label>
<select id="repeat_edate_field_id" name="options[repeat_edate_field_id]">
    <option value=""><?php 
_e('Never', 'formidable');
?>
</option>
    <?php 
if (is_numeric($post->frm_form_id) && !empty($post->frm_form_id)) {
    FrmProFieldsHelper::get_field_options($post->frm_form_id, $post->frm_repeat_edate_field_id, '', "'date'");
}
?>
</select>