Ejemplo n.º 1
0
 function entry_created($entry_id, $form_id)
 {
     if (apply_filters('frm_stop_standard_email', false, $entry_id)) {
         return;
     }
     global $frm_entry, $frm_entry_meta;
     $entry = $frm_entry->getOne($entry_id, true);
     $frm_form = new FrmForm();
     $form = $frm_form->getOne($form_id);
     $values = $frm_entry_meta->getAll("it.item_id = {$entry_id}", " ORDER BY fi.field_order");
     if (isset($form->options['notification'])) {
         $notification = reset($form->options['notification']);
     } else {
         $notification = $form->options;
     }
     // Set the from and to email names and addresses
     $to_email = $notification['email_to'];
     if (empty($to_email)) {
         $to_email = '[admin_email]';
     }
     $to_emails = explode(',', $to_email);
     $reply_to = $reply_to_name = '';
     foreach ($values as $value) {
         $val = apply_filters('frm_email_value', maybe_unserialize($value->meta_value), $value, $entry);
         if (is_array($val)) {
             $val = implode(', ', $val);
         }
         if (isset($notification['reply_to']) and (int) $notification['reply_to'] == $value->field_id and is_email($val)) {
             $reply_to = $val;
         }
         if (isset($notification['reply_to_name']) and (int) $notification['reply_to_name'] == $value->field_id) {
             $reply_to_name = $val;
         }
     }
     if (empty($reply_to) && $notification['reply_to'] == 'custom') {
         $reply_to = $notification['cust_reply_to'];
     }
     if (empty($reply_to_name) && $notification['reply_to_name'] == 'custom') {
         $reply_to_name = $notification['cust_reply_to_name'];
     }
     // Set the email message
     $plain_text = isset($notification['plain_text']) && $notification['plain_text'] ? true : false;
     $mail_body = isset($notification['email_message']) ? $notification['email_message'] : '';
     $mail_body = FrmEntriesHelper::replace_default_message($mail_body, array('id' => $entry->id, 'entry' => $entry, 'plain_text' => $plain_text, 'user_info' => isset($notification['inc_user_info']) ? $notification['inc_user_info'] : false));
     // Set the subject
     $subject = isset($notification['email_subject']) ? $notification['email_subject'] : '';
     if (empty($subject)) {
         $frm_blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
         $subject = sprintf(__('%1$s Form submitted on %2$s', 'formidable'), $form->name, $frm_blogname);
     }
     // Send the emails now
     foreach ((array) $to_emails as $to_email) {
         $this->send_notification_email(trim($to_email), $subject, $mail_body, $reply_to, $reply_to_name, $plain_text);
     }
 }
Ejemplo n.º 2
0
 public static function validate($params, $fields, $form, $title, $description)
 {
     global $frm_vars;
     $frm_settings = FrmAppHelper::get_settings();
     if (($_POST && isset($_POST['frm_page_order_' . $form->id]) || FrmProFormsHelper::going_to_prev($form->id)) && !FrmProFormsHelper::saving_draft()) {
         $errors = '';
         $fields = FrmFieldsHelper::get_form_fields($form->id);
         $submit = isset($form->options['submit_value']) ? $form->options['submit_value'] : $frm_settings->submit_value;
         $values = $fields ? FrmEntriesHelper::setup_new_vars($fields, $form) : array();
         require FrmAppHelper::plugin_path() . '/classes/views/frm-entries/new.php';
         add_filter('frm_continue_to_create', '__return_false');
     } else {
         if ($form->editable && isset($form->options['single_entry']) && $form->options['single_entry'] && $form->options['single_entry_type'] == 'user') {
             $user_ID = get_current_user_id();
             if ($user_ID) {
                 $entry = FrmEntry::getAll(array('it.user_id' => $user_ID, 'it.form_id' => $form->id), '', 1, true);
                 if ($entry) {
                     $entry = reset($entry);
                 }
             } else {
                 $entry = false;
             }
             if ($entry && !empty($entry) && (!isset($frm_vars['created_entries'][$form->id]) || !isset($frm_vars['created_entries'][$form->id]['entry_id']) || $entry->id != $frm_vars['created_entries'][$form->id]['entry_id'])) {
                 FrmProEntriesController::show_responses($entry, $fields, $form, $title, $description);
             } else {
                 $record = $frm_vars['created_entries'][$form->id]['entry_id'];
                 $saved_message = isset($form->options['success_msg']) ? $form->options['success_msg'] : $frm_settings->success_msg;
                 if (FrmProFormsHelper::saving_draft()) {
                     $saved_message = isset($form->options['draft_msg']) ? $form->options['draft_msg'] : __('Your draft has been saved.', 'formidable');
                 }
                 $saved_message = apply_filters('frm_content', $saved_message, $form, $record ? $record : false);
                 $message = wpautop(do_shortcode($record ? $saved_message : $frm_settings->failed_msg));
                 $message = '<div class="frm_message" id="message">' . $message . '</div>';
                 FrmProEntriesController::show_responses($record, $fields, $form, $title, $description, $message);
             }
             add_filter('frm_continue_to_create', '__return_false');
         } else {
             if (FrmProFormsHelper::saving_draft()) {
                 $record = isset($frm_vars['created_entries']) && isset($frm_vars['created_entries'][$form->id]) ? $frm_vars['created_entries'][$form->id]['entry_id'] : 0;
                 if (!$record) {
                     return;
                 }
                 $saved_message = '';
                 FrmProFormsHelper::save_draft_msg($saved_message, $form, $record);
                 $message = FrmFormsHelper::get_success_message(array('message' => $saved_message, 'form' => $form, 'entry_id' => $record, 'class' => 'frm_message'));
                 FrmProEntriesController::show_responses($record, $fields, $form, $title, $description, $message);
                 add_filter('frm_continue_to_create', '__return_false');
             }
         }
     }
 }
Ejemplo n.º 3
0
 private static function add_field_values_to_csv(&$row)
 {
     foreach (self::$fields as $col) {
         $field_value = isset(self::$entry->metas[$col->id]) ? self::$entry->metas[$col->id] : false;
         // Post values need to be retrieved differently
         if (self::$entry->post_id && ($col->type == 'tag' || isset($col->field_options['post_field']) && $col->field_options['post_field'])) {
             $field_value = FrmProEntryMetaHelper::get_post_value(self::$entry->post_id, $col->field_options['post_field'], $col->field_options['custom_field'], array('truncate' => $col->field_options['post_field'] == 'post_category' ? true : false, 'form_id' => self::$entry->form_id, 'field' => $col, 'type' => $col->type, 'exclude_cat' => isset($col->field_options['exclude_cat']) ? $col->field_options['exclude_cat'] : 0, 'sep' => self::$separator));
         }
         if (in_array($col->type, array('user_id', 'file', 'date', 'data'))) {
             $field_value = FrmProFieldsHelper::get_export_val($field_value, $col, self::$entry);
         } else {
             if (isset($col->field_options['separate_value']) && $col->field_options['separate_value']) {
                 $sep_value = FrmEntriesHelper::display_value($field_value, $col, array('type' => $col->type, 'post_id' => self::$entry->post_id, 'show_icon' => false, 'entry_id' => self::$entry->id, 'sep' => self::$separator, 'embedded_field_id' => isset(self::$entry->embedded_fields) && isset(self::$entry->embedded_fields[$entry->id]) ? 'form' . self::$entry->embedded_fields[self::$entry->id] : 0));
                 $row[$col->id . '_label'] = $sep_value;
                 unset($sep_value);
             }
             $field_value = maybe_unserialize($field_value);
             $field_value = apply_filters('frm_csv_value', $field_value, array('field' => $col));
         }
         $row[$col->id] = $field_value;
         unset($col, $field_value);
     }
 }
 private function get_column_value($item, &$val)
 {
     $col_name = $this->column_name;
     if (strpos($col_name, 'frmsep_') === 0) {
         $sep_val = true;
         $col_name = str_replace('frmsep_', '', $col_name);
     } else {
         $sep_val = false;
     }
     if (strpos($col_name, '-_-')) {
         list($col_name, $embedded_field_id) = explode('-_-', $col_name);
     }
     $field = FrmField::getOne($col_name);
     if (!$field) {
         return;
     }
     $atts = array('type' => $field->type, 'truncate' => true, 'post_id' => $item->post_id, 'entry_id' => $item->id, 'embedded_field_id' => 0);
     if ($sep_val) {
         $atts['saved_value'] = true;
     }
     if (isset($embedded_field_id)) {
         $atts['embedded_field_id'] = $embedded_field_id;
         unset($embedded_field_id);
     }
     $val = FrmEntriesHelper::prepare_display_value($item, $field, $atts);
 }
Ejemplo n.º 5
0
 function akismet($values)
 {
     $content = FrmEntriesHelper::entry_array_to_string($values);
     if (empty($content)) {
         return false;
     }
     $datas = array();
     $datas['blog'] = FrmAppHelper::site_url();
     $datas['user_ip'] = preg_replace('/[^0-9., ]/', '', $_SERVER['REMOTE_ADDR']);
     $datas['user_agent'] = $_SERVER['HTTP_USER_AGENT'];
     $datas['referrer'] = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : false;
     $datas['comment_type'] = 'formidable';
     if ($permalink = get_permalink()) {
         $datas['permalink'] = $permalink;
     }
     $datas['comment_content'] = $content;
     foreach ($_SERVER as $key => $value) {
         if (!in_array($key, array('HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW')) && is_string($value)) {
             $datas["{$key}"] = $value;
         } else {
             $datas["{$key}"] = '';
         }
         unset($key, $value);
     }
     $query_string = '';
     foreach ($datas as $key => $data) {
         $query_string .= $key . '=' . urlencode(stripslashes($data)) . '&';
         unset($key, $data);
     }
     if (is_callable('Akismet::http_post')) {
         $response = Akismet::http_post($query_string, 'comment-check');
     } else {
         global $akismet_api_host, $akismet_api_port;
         $response = akismet_http_post($query_string, $akismet_api_host, '/1.1/comment-check', $akismet_api_port);
     }
     return (is_array($response) and $response[1] == 'true') ? true : false;
 }
Ejemplo n.º 6
0
?>
</span></h3>
<div class="inside">
<table class="form-table">
    <tr class="form-field">
        <th valign="top" scope="row"><?php 
_e('Use Entries from Form', 'formidable');
?>
</th>
        <td><?php 
FrmFormsHelper::forms_dropdown('form_id', $values['form_id'], true, false, "frmDisplayFormSelected(this.value,'{$frm_ajax_url}')");
?>
            <span id="entry_select_container">
                <?php 
if (is_numeric($values['form_id'])) {
    _e('Select Entry', 'formidable') . ': ' . FrmEntriesHelper::entries_dropdown($values['form_id'], 'entry_id', $values['entry_id'], true, __('The first one depending on the Order specified below', 'formidable'));
}
?>
            </span>
        </td>
    </tr>
    <tr class="form-field">
        <th valign="top" scope="row"><?php 
_e('Display Format', 'formidable');
?>
</th>
        <td>
            <fieldset>
            <p><label for="all"><input type="radio" value="all" id="all" <?php 
checked($values['show_count'], 'all');
?>
Ejemplo n.º 7
0
 function get_new_vars($errors = '', $form = '', $message = '')
 {
     global $frm_form, $frm_field, $frm_entry, $frm_settings, $frm_next_page;
     $title = true;
     $description = true;
     $fields = FrmFieldsHelper::get_form_fields($form->id, !empty($errors));
     $values = FrmEntriesHelper::setup_new_vars($fields, $form);
     $submit = isset($frm_next_page[$form->id]) ? $frm_next_page[$form->id] : (isset($values['submit_value']) ? $values['submit_value'] : $frm_settings->submit_value);
     require_once FRMPRO_VIEWS_PATH . '/frmpro-entries/new.php';
 }
Ejemplo n.º 8
0
 /**
  * Check entries for spam
  *
  * @return boolean true if is spam
  */
 public static function akismet($values)
 {
     $content = FrmEntriesHelper::entry_array_to_string($values);
     if (empty($content)) {
         return false;
     }
     $datas = array();
     self::parse_akismet_array($datas, $content);
     $query_string = '';
     foreach ($datas as $key => $data) {
         $query_string .= $key . '=' . urlencode(stripslashes($data)) . '&';
         unset($key, $data);
     }
     $response = Akismet::http_post($query_string, 'comment-check');
     return is_array($response) && $response[1] == 'true';
 }
Ejemplo n.º 9
0
 function setup_edit_vars($record, $table, $fields = '', $default = false)
 {
     if (!$record) {
         return false;
     }
     global $frm_entry_meta, $frm_form, $frm_settings, $frm_sidebar_width;
     $values = array();
     $values['id'] = $record->id;
     foreach (array('name' => $record->name, 'description' => $record->description) as $var => $default_val) {
         $values[$var] = stripslashes(FrmAppHelper::get_param($var, $default_val));
     }
     if (apply_filters('frm_use_wpautop', true)) {
         $values['description'] = wpautop($values['description']);
     }
     $values['fields'] = array();
     if ($fields) {
         foreach ($fields as $field) {
             $field->field_options = stripslashes_deep(maybe_unserialize($field->field_options));
             if ($default) {
                 $meta_value = $field->default_value;
             } else {
                 if ($record->post_id and class_exists('FrmProEntryMetaHelper') and isset($field->field_options['post_field']) and $field->field_options['post_field']) {
                     $meta_value = FrmProEntryMetaHelper::get_post_value($record->post_id, $field->field_options['post_field'], $field->field_options['custom_field'], array('truncate' => false, 'type' => $field->type, 'form_id' => $field->form_id, 'field' => $field));
                 } else {
                     if (isset($record->metas)) {
                         $meta_value = isset($record->metas[$field->id]) ? $record->metas[$field->id] : false;
                     } else {
                         $meta_value = $frm_entry_meta->get_entry_meta_by_field($record->id, $field->id);
                     }
                 }
             }
             $field_type = isset($_POST['field_options']['type_' . $field->id]) ? $_POST['field_options']['type_' . $field->id] : $field->type;
             $new_value = isset($_POST['item_meta'][$field->id]) ? $_POST['item_meta'][$field->id] : $meta_value;
             $new_value = maybe_unserialize($new_value);
             if (is_array($new_value)) {
                 $new_value = stripslashes_deep($new_value);
             }
             $field_array = array('id' => $field->id, 'value' => $new_value, 'default_value' => stripslashes_deep(maybe_unserialize($field->default_value)), 'name' => stripslashes($field->name), 'description' => stripslashes($field->description), 'type' => apply_filters('frm_field_type', $field_type, $field, $new_value), 'options' => stripslashes_deep(maybe_unserialize($field->options)), 'required' => $field->required, 'field_key' => $field->field_key, 'field_order' => $field->field_order, 'form_id' => $field->form_id);
             /*if(in_array($field_array['type'], array('checkbox', 'radio', 'select')) and !empty($field_array['options'])){
                   foreach((array)$field_array['options'] as $opt_key => $opt){
                       if(!is_array($opt))
                           $field_array['options'][$opt_key] = array('label' => $opt);
                       unset($opt);
                       unset($opt_key);
                   }
               }*/
             $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
             foreach ($opt_defaults as $opt => $default_opt) {
                 $field_array[$opt] = ($_POST and isset($_POST['field_options'][$opt . '_' . $field->id])) ? $_POST['field_options'][$opt . '_' . $field->id] : (isset($field->field_options[$opt]) ? $field->field_options[$opt] : $default_opt);
                 if ($opt == 'blank' and $field_array[$opt] == '') {
                     $field_array[$opt] = __('This field cannot be blank', 'formidable');
                 } else {
                     if ($opt == 'invalid' and $field_array[$opt] == '') {
                         if ($field_type == 'captcha') {
                             $field_array[$opt] = $frm_settings->re_msg;
                         } else {
                             $field_array[$opt] = $field_array['name'] . ' ' . __('is invalid', 'formidable');
                         }
                     }
                 }
             }
             unset($opt_defaults);
             if ($field_array['custom_html'] == '') {
                 $field_array['custom_html'] = FrmFieldsHelper::get_default_html($field_type);
             }
             if ($field_array['size'] == '') {
                 $field_array['size'] = $frm_sidebar_width;
             }
             $values['fields'][] = apply_filters('frm_setup_edit_fields_vars', stripslashes_deep($field_array), $field, $values['id']);
             unset($field);
         }
     }
     if ($table == 'entries') {
         $form = $frm_form->getOne($record->form_id);
     } else {
         if ($table == 'forms') {
             $form = $frm_form->getOne($record->id);
         }
     }
     if ($form) {
         $form->options = maybe_unserialize($form->options);
         $values['form_name'] = isset($record->form_id) ? $form->name : '';
         if (is_array($form->options)) {
             foreach ($form->options as $opt => $value) {
                 $values[$opt] = FrmAppHelper::get_param($opt, $value);
             }
         }
     }
     $form_defaults = FrmFormsHelper::get_default_opts();
     $form_defaults['email_to'] = '';
     //options to allow blank answers
     foreach (array('email_to', 'reply_to', 'reply_to_name') as $opt) {
         if (!isset($values[$opt])) {
             $values[$opt] = ($_POST and isset($_POST['options'][$opt])) ? $_POST['options'][$opt] : $form_defaults[$opt];
             unset($form_defaults[$opt]);
             unset($opt);
         }
     }
     //don't allow blank answers
     foreach ($form_defaults as $opt => $default) {
         if (!isset($values[$opt]) or $values[$opt] == '') {
             $values[$opt] = ($_POST and isset($_POST['options'][$opt])) ? $_POST['options'][$opt] : $default;
         }
         unset($opt);
         unset($defaut);
     }
     if (!isset($values['custom_style'])) {
         $values['custom_style'] = ($_POST and isset($_POST['options']['custom_style'])) ? $_POST['options']['custom_style'] : $frm_settings->load_style != 'none';
     }
     if (!isset($values['before_html'])) {
         $values['before_html'] = isset($_POST['options']['before_html']) ? $_POST['options']['before_html'] : FrmFormsHelper::get_default_html('before');
     }
     if (!isset($values['after_html'])) {
         $values['after_html'] = isset($_POST['options']['after_html']) ? $_POST['options']['after_html'] : FrmFormsHelper::get_default_html('after');
     }
     if ($table == 'entries') {
         $values = FrmEntriesHelper::setup_edit_vars($values, $record);
     } else {
         if ($table == 'forms') {
             $values = FrmFormsHelper::setup_edit_vars($values, $record);
         }
     }
     return $values;
 }
Ejemplo n.º 10
0
 public static function repeat_field_set($field_name, $args = array())
 {
     $defaults = array('i' => 0, 'entry_id' => false, 'form' => false, 'fields' => array(), 'errors' => array(), 'parent_field' => 0, 'repeat' => 0, 'row_count' => false, 'value' => '', 'field_name' => '');
     $args = wp_parse_args($args, $defaults);
     if (empty($args['parent_field'])) {
         return;
     }
     if (is_numeric($args['parent_field'])) {
         $args['parent_field'] = (array) FrmField::getOne($args['parent_field']);
         $args['parent_field']['format'] = isset($args['parent_field']['field_options']['format']) ? $args['parent_field']['field_options']['format'] : '';
     }
     FrmForm::maybe_get_form($args['form']);
     if (empty($args['fields'])) {
         $args['fields'] = FrmField::get_all_for_form($args['form']->id);
     }
     $values = array();
     if ($args['fields']) {
         // Get the ID of the form that houses the embedded form or repeating section
         $parent_form_id = $args['parent_field']['form_id'];
         if (empty($args['entry_id'])) {
             $values = FrmEntriesHelper::setup_new_vars($args['fields'], $args['form'], false, array('parent_form_id' => $parent_form_id));
         } else {
             $entry = FrmEntry::getOne($args['entry_id'], true);
             if ($entry && $entry->form_id == $args['form']->id) {
                 $values = FrmAppHelper::setup_edit_vars($entry, 'entries', $args['fields'], false, array(), array('parent_form_id' => $parent_form_id));
             } else {
                 return;
             }
         }
     }
     $format = isset($args['parent_field']['format']) ? $args['parent_field']['format'] : '';
     $end = false;
     $count = 0;
     foreach ($values['fields'] as $subfield) {
         if ('end_divider' == $subfield['type']) {
             $end = $subfield;
         } else {
             if (!in_array($subfield['type'], array('hidden', 'user_id'))) {
                 if (isset($subfield['conf_field']) && $subfield['conf_field']) {
                     $count = $count + 2;
                 } else {
                     $count++;
                 }
             }
         }
         unset($subfield);
     }
     if ($args['repeat']) {
         $count++;
     }
     $classes = array(2 => 'half', 3 => 'third', 4 => 'fourth', 5 => 'fifth', 6 => 'sixth', 7 => 'seventh', 8 => 'eighth');
     $field_class = !empty($format) && isset($classes[$count]) ? $classes[$count] : '';
     echo '<div id="frm_section_' . $args['parent_field']['id'] . '-' . $args['i'] . '" class="frm_repeat_' . (empty($format) ? 'sec' : $format) . ' frm_repeat_' . $args['parent_field']['id'] . ($args['row_count'] === 0 ? ' frm_first_repeat' : '') . '">' . "\n";
     self::add_hidden_repeat_entry_id($args);
     self::add_default_item_meta_field($args);
     $label_pos = 'top';
     $field_num = 1;
     foreach ($values['fields'] as $subfield) {
         $subfield_name = $field_name . '[' . $args['i'] . '][' . $subfield['id'] . ']';
         $subfield_plus_id = '-' . $args['i'];
         $subfield_id = $subfield['id'] . '-' . $args['parent_field']['id'] . $subfield_plus_id;
         if ($args['parent_field'] && !empty($args['parent_field']['value']) && isset($args['parent_field']['value']['form']) && isset($args['parent_field']['value'][$args['i']]) && isset($args['parent_field']['value'][$args['i']][$subfield['id']])) {
             // this is a posted value from moving between pages, so set the POSTed value
             $subfield['value'] = $args['parent_field']['value'][$args['i']][$subfield['id']];
         }
         if (!empty($field_class)) {
             if (1 == $field_num) {
                 $subfield['classes'] .= ' frm_first frm_' . $field_class;
             } else {
                 $subfield['classes'] .= ' frm_' . $field_class;
             }
         }
         $field_num++;
         if ('top' == $label_pos && in_array($subfield['label'], array('top', 'hidden', ''))) {
             // add placeholder label if repeating
             $label_pos = 'hidden';
         }
         $field_args = array('field_name' => $subfield_name, 'field_id' => $subfield_id, 'field_plus_id' => $subfield_plus_id, 'section_id' => $args['parent_field']['id']);
         if (apply_filters('frm_show_normal_field_type', true, $subfield['type'])) {
             echo FrmFieldsHelper::replace_shortcodes($subfield['custom_html'], $subfield, $args['errors'], $args['form'], $field_args);
         } else {
             do_action('frm_show_other_field_type', $subfield, $args['form'], $field_args);
         }
         unset($subfield_name, $subfield_id);
         do_action('frm_get_field_scripts', $subfield, $args['form'], $args['parent_field']['form_id']);
     }
     if (!$args['repeat']) {
         // Close frm_repeat div
         echo '</div>' . "\n";
         return;
     }
     $args['format'] = $format;
     $args['label_pos'] = $label_pos;
     $args['field_class'] = $field_class;
     echo self::repeat_buttons($args, $end);
     // Close frm_repeat div
     echo '</div>' . "\n";
 }
Ejemplo n.º 11
0
 private static function add_field_values_to_csv(&$row)
 {
     foreach (self::$fields as $col) {
         $field_value = isset(self::$entry->metas[$col->id]) ? self::$entry->metas[$col->id] : false;
         $field_value = maybe_unserialize($field_value);
         $field_value = apply_filters('frm_csv_value', $field_value, array('field' => $col, 'entry' => self::$entry, 'separator' => self::$separator));
         if (isset($col->field_options['separate_value']) && $col->field_options['separate_value']) {
             $sep_value = FrmEntriesHelper::display_value($field_value, $col, array('type' => $col->type, 'post_id' => self::$entry->post_id, 'show_icon' => false, 'entry_id' => self::$entry->id, 'sep' => self::$separator, 'embedded_field_id' => isset(self::$entry->embedded_fields) && isset(self::$entry->embedded_fields[self::$entry->id]) ? 'form' . self::$entry->embedded_fields[self::$entry->id] : 0));
             $row[$col->id . '_label'] = $sep_value;
             unset($sep_value);
         }
         $row[$col->id] = $field_value;
         unset($col, $field_value);
     }
 }
Ejemplo n.º 12
0
 public static function entry_created($entry_id, $form_id, $create = true)
 {
     if (defined('WP_IMPORTING')) {
         return;
     }
     global $frm_field, $frm_entry, $frm_entry_meta, $frmpro_settings;
     $frm_form = new FrmForm();
     $form = $frm_form->getOne($form_id);
     if (!$form) {
         return;
     }
     $form_options = maybe_unserialize($form->options);
     $entry = $frm_entry->getOne($entry_id, true);
     if (!$entry or $entry->form_id != $form_id or $entry->is_draft) {
         return;
     }
     $sent_to = array();
     $notifications = isset($form_options['notification']) ? $form_options['notification'] : array(0 => $form_options);
     $fields = $frm_field->getAll(array('fi.form_id' => $form_id), 'field_order');
     $temp_fields = array();
     foreach ($fields as $k => $f) {
         if (!isset($entry->metas[$f->id])) {
             $f->field_options = maybe_unserialize($f->field_options);
             if (isset($f->field_options['post_field']) and !empty($f->field_options['post_field'])) {
                 //get value from linked post
                 $entry->metas[$f->id] = FrmProEntryMetaHelper::get_post_or_meta_value($entry, $f, array('links' => false));
                 if ($entry->metas[$f->id] == '') {
                     //and !include_blank
                     unset($entry->metas[$f->id]);
                 }
                 //}else if(include_blank){
                 //    $entry->metas[$f->id] = '';
             }
         }
         $temp_fields[$f->id] = $f;
         unset($fields[$k]);
         unset($k);
         unset($f);
     }
     $fields = $temp_fields;
     unset($temp_fields);
     $frm_notification = new FrmNotification();
     foreach ($notifications as $email_key => $notification) {
         if (isset($notification['update_email'])) {
             if ($create and $notification['update_email'] == 2) {
                 continue;
             }
             if (!$create and empty($notification['update_email'])) {
                 continue;
             }
         }
         //check if conditions are met
         $stop = self::conditions_met($notification, $entry);
         if ($stop) {
             continue;
         }
         unset($stop);
         $to_email = explode(',', $notification['email_to']);
         $email_fields = isset($notification['also_email_to']) ? (array) $notification['also_email_to'] : array();
         $email_fields = array_merge($email_fields, $to_email);
         $entry_ids = array($entry->id);
         $exclude_fields = array();
         foreach ($email_fields as $key => $email_field) {
             $email_field = str_replace(array('[', ']'), '', trim($email_field));
             if (is_numeric($email_field)) {
                 $email_fields[$key] = (int) $email_field;
             }
             if (preg_match('/|/', $email_field)) {
                 $email_opt = explode('|', $email_field);
                 if (isset($email_opt[1])) {
                     if (isset($entry->metas[$email_opt[0]])) {
                         $add_id = $entry->metas[$email_opt[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;
                         }
                     }
                     //skip the data field if it will be fetched through the other form
                     $exclude_fields[] = $email_opt[0];
                     $email_fields[$key] = (int) $email_opt[1];
                 }
                 unset($email_opt);
             }
         }
         if (empty($to_email) and empty($email_fields)) {
             continue;
         }
         foreach ($email_fields as $email_field) {
             if (isset($notification['reply_to_name']) and preg_match('/|/', $email_field)) {
                 $email_opt = explode('|', $notification['reply_to_name']);
                 if (isset($email_opt[1])) {
                     if (isset($entry->metas[$email_opt[0]])) {
                         $entry_ids[] = $entry->metas[$email_opt[0]];
                     }
                     //skip the data field if it will be fetched through the other form
                     $exclude_fields[] = $email_opt[0];
                 }
                 unset($email_opt);
             }
         }
         $where = '';
         if (!empty($exclude_fields)) {
             $where = " and it.field_id not in (" . implode(',', $exclude_fields) . ")";
         }
         $values = $frm_entry_meta->getAll("it.field_id != 0 and it.item_id in (" . implode(',', $entry_ids) . ")" . $where, " ORDER BY fi.field_order");
         $to_emails = $to_email ? $to_email : array();
         $plain_text = (isset($notification['plain_text']) and $notification['plain_text']) ? true : false;
         $custom_message = false;
         $mail_body = '';
         if (isset($notification['email_message']) and trim($notification['email_message']) != '') {
             if (isset($notification['ar']) and $notification['ar']) {
                 //don't continue with blank autoresponder message for reverse compatability
                 if ($notification['email_message'] == '') {
                     continue;
                 }
                 $notification['email_message'] = apply_filters('frm_ar_message', $notification['email_message'], array('entry' => $entry, 'form' => $form));
             }
             $custom_message = true;
             $shortcodes = FrmProAppHelper::get_shortcodes($notification['email_message'], $entry->form_id);
             $mail_body = FrmProFieldsHelper::replace_shortcodes($notification['email_message'], $entry, $shortcodes);
         }
         $reply_to_name = $frm_blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
         //default sender name
         $odd = true;
         $attachments = array();
         foreach ($values as $value) {
             $field = isset($fields[$value->field_id]) ? $fields[$value->field_id] : false;
             $prev_val = maybe_unserialize($value->meta_value);
             if ($value->field_type == 'file') {
                 global $frmdb;
                 if ($field) {
                     $file_options = $field->field_options;
                 } else {
                     $file_options = $frmdb->get_var($frmdb->fields, array('id' => $value->field_id), 'field_options');
                 }
                 $file_options = maybe_unserialize($file_options);
                 if (isset($file_options['attach']) and $file_options['attach']) {
                     foreach ((array) $prev_val as $m) {
                         $file = get_post_meta($m, '_wp_attached_file', true);
                         if ($file) {
                             if (!isset($uploads) or !isset($uploads['basedir'])) {
                                 $uploads = wp_upload_dir();
                             }
                             $attachments[] = $uploads['basedir'] . "/{$file}";
                         }
                         unset($m);
                     }
                 }
                 unset($file_options);
             }
             $val = apply_filters('frm_email_value', $prev_val, $value, $entry);
             if ($value->field_type == 'textarea' and !$plain_text) {
                 $val = str_replace(array("\r\n", "\r", "\n"), ' <br/>', $val);
             }
             if (is_array($val)) {
                 $val = implode(', ', $val);
             }
             if (isset($notification['reply_to']) and (int) $notification['reply_to'] == $value->field_id) {
                 if ($value->field_type == 'user_id') {
                     $user_data = get_userdata($value->meta_value);
                     $reply_to = $user_data->user_email;
                 } else {
                     if (is_email($val)) {
                         $reply_to = $val;
                     } else {
                         if (is_email($prev_val)) {
                             $reply_to = $prev_val;
                         }
                     }
                 }
             }
             if (isset($notification['reply_to_name']) and (int) $notification['reply_to_name'] == $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 = $val;
                 }
             }
             if (in_array($value->field_id, $email_fields)) {
                 if ($value->field_type == 'user_id') {
                     $user_data = get_userdata($value->meta_value);
                     $to_emails[] = $user_data->user_email;
                 } else {
                     $val = explode(',', $val);
                     $prev_val = explode(',', $prev_val);
                     if (is_array($val) or is_array($prev_val)) {
                         foreach ((array) $val as $v) {
                             $v = trim($v);
                             if (is_email($v)) {
                                 $to_emails[] = $v;
                             }
                             unset($v);
                         }
                         foreach ((array) $prev_val as $v) {
                             $v = trim($v);
                             if (is_email($v) and !in_array($v, $to_emails)) {
                                 $to_emails[] = $v;
                             }
                             unset($v);
                         }
                     } else {
                         if (is_email($val)) {
                             $to_emails[] = $val;
                         } else {
                             if (is_email($prev_val)) {
                                 $to_emails[] = $prev_val;
                             }
                         }
                     }
                 }
             }
         }
         unset($prev_val);
         $attachments = apply_filters('frm_notification_attachment', $attachments, $form, array('entry' => $entry, 'email_key' => $email_key));
         if (isset($notification['ar']) and $notification['ar']) {
             $attachments = apply_filters('frm_autoresponder_attachment', array(), $form);
         }
         if (!isset($reply_to)) {
             $reply_to = '[admin_email]';
         }
         if ($notification['reply_to'] == 'custom') {
             $reply_to = isset($notification['cust_reply_to']) ? $notification['cust_reply_to'] : $reply_to;
         }
         if (empty($reply_to)) {
             $reply_to = '[admin_email]';
             //global $frm_settings;
             //$reply_to = $frm_settings->email_to;
         }
         if ($notification['reply_to_name'] == 'custom') {
             $reply_to_name = isset($notification['cust_reply_to_name']) ? $notification['cust_reply_to_name'] : $reply_to_name;
             $reply_to_name = apply_filters('frm_content', $reply_to_name, $form, $entry_id);
         }
         $prev_mail_body = $mail_body;
         $mail_body = FrmEntriesHelper::replace_default_message($mail_body, array('id' => $entry->id, 'entry' => $entry, 'plain_text' => $plain_text, 'fields' => $fields, 'user_info' => isset($notification['inc_user_info']) ? $notification['inc_user_info'] : false));
         if (isset($notification['inc_user_info']) && $notification['inc_user_info'] && $prev_mail_body == $mail_body) {
             $data = maybe_unserialize($entry->description);
             $mail_body .= "\r\n\r\n" . __('User Information', 'formidable') . "\r\n";
             $mail_body .= __('IP Address', 'formidable') . ": " . $entry->ip . "\r\n";
             $mail_body .= __('User-Agent (Browser/OS)', 'formidable') . ": " . $data['browser'] . "\r\n";
             $mail_body .= __('Referrer', 'formidable') . ": " . $data['referrer'] . "\r\n";
         }
         unset($prev_mail_body);
         if (isset($notification['email_subject']) and $notification['email_subject'] != '') {
             $shortcodes = FrmProAppHelper::get_shortcodes($notification['email_subject'], $entry->form_id);
             $subject = FrmProFieldsHelper::replace_shortcodes($notification['email_subject'], $entry, $shortcodes);
             $subject = apply_filters('frm_email_subject', $subject, compact('form', 'entry', 'email_key'));
             if (isset($notification['ar']) and $notification['ar']) {
                 $subject = apply_filters('frm_ar_subject', $subject, $form);
             }
         } else {
             //set default subject
             $subject = sprintf(__('%1$s Form submitted on %2$s', 'formidable'), $form->name, $frm_blogname);
         }
         $to_emails = apply_filters('frm_to_email', $to_emails, $values, $form_id, compact('email_key', 'entry'));
         $to_emails = array_unique((array) $to_emails);
         $sent = array();
         foreach ((array) $to_emails as $to_email) {
             $to_email = apply_filters('frm_content', $to_email, $form, $entry_id);
             $to_email = do_shortcode($to_email);
             if (strpos($to_email, ',')) {
                 $to_email = explode(',', $to_email);
             }
             foreach ((array) $to_email as $e) {
                 $e = trim($e);
                 if (($e == '[admin_email]' or is_email($e)) and !in_array($e, $sent)) {
                     $sent_to[] = $sent[] = $e;
                     $frm_notification->send_notification_email($e, $subject, $mail_body, $reply_to, $reply_to_name, $plain_text, $attachments);
                 } else {
                     if (!in_array($e, $sent)) {
                         do_action('frm_send_to_not_email', compact('e', 'subject', 'mail_body', 'reply_to', 'reply_to_name', 'plain_text', 'attachments', 'form', 'email_key'));
                     }
                 }
                 unset($e);
             }
             unset($to_email);
         }
         unset($sent, $to_emails, $notification, $subject, $mail_body);
         unset($reply_to, $reply_to_name, $plain_text, $attachments);
     }
     return $sent_to;
 }
Ejemplo n.º 13
0
 public static function setup_edit_vars($record, $table, $fields = '', $default = false, $post_values = array())
 {
     if (!$record) {
         return false;
     }
     global $frm_entry_meta, $frm_settings, $frm_vars;
     if (empty($post_values)) {
         $post_values = stripslashes_deep($_POST);
     }
     $values = array('id' => $record->id, 'fields' => array());
     foreach (array('name', 'description') as $var) {
         $default_val = isset($record->{$var}) ? $record->{$var} : '';
         $values[$var] = FrmAppHelper::get_param($var, $default_val);
         unset($var, $default_val);
     }
     if (apply_filters('frm_use_wpautop', true)) {
         $values['description'] = wpautop(str_replace('<br>', '<br />', $values['description']));
     }
     foreach ((array) $fields as $field) {
         if ($default) {
             $meta_value = $field->default_value;
         } else {
             if ($record->post_id and class_exists('FrmProEntryMetaHelper') and isset($field->field_options['post_field']) and $field->field_options['post_field']) {
                 if (!isset($field->field_options['custom_field'])) {
                     $field->field_options['custom_field'] = '';
                 }
                 $meta_value = FrmProEntryMetaHelper::get_post_value($record->post_id, $field->field_options['post_field'], $field->field_options['custom_field'], array('truncate' => false, 'type' => $field->type, 'form_id' => $field->form_id, 'field' => $field));
             } else {
                 if (isset($record->metas)) {
                     $meta_value = isset($record->metas[$field->id]) ? $record->metas[$field->id] : false;
                 } else {
                     $meta_value = $frm_entry_meta->get_entry_meta_by_field($record->id, $field->id);
                 }
             }
         }
         $field_type = isset($post_values['field_options']['type_' . $field->id]) ? $post_values['field_options']['type_' . $field->id] : $field->type;
         $new_value = isset($post_values['item_meta'][$field->id]) ? maybe_unserialize($post_values['item_meta'][$field->id]) : $meta_value;
         $field_array = array('id' => $field->id, 'value' => $new_value, 'default_value' => $field->default_value, 'name' => $field->name, 'description' => $field->description, 'type' => apply_filters('frm_field_type', $field_type, $field, $new_value), 'options' => $field->options, 'required' => $field->required, 'field_key' => $field->field_key, 'field_order' => $field->field_order, 'form_id' => $field->form_id);
         /*if(in_array($field_array['type'], array('checkbox', 'radio', 'select')) and !empty($field_array['options'])){
               foreach((array)$field_array['options'] as $opt_key => $opt){
                   if(!is_array($opt))
                       $field_array['options'][$opt_key] = array('label' => $opt);
                   unset($opt);
                   unset($opt_key);
               }
           }*/
         $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
         foreach ($opt_defaults as $opt => $default_opt) {
             $field_array[$opt] = $post_values && isset($post_values['field_options'][$opt . '_' . $field->id]) ? maybe_unserialize($post_values['field_options'][$opt . '_' . $field->id]) : (isset($field->field_options[$opt]) ? $field->field_options[$opt] : $default_opt);
             if ($opt == 'blank' and $field_array[$opt] == '') {
                 $field_array[$opt] = $frm_settings->blank_msg;
             } else {
                 if ($opt == 'invalid' and $field_array[$opt] == '') {
                     if ($field_type == 'captcha') {
                         $field_array[$opt] = $frm_settings->re_msg;
                     } else {
                         $field_array[$opt] = sprintf(__('%s is invalid', 'formidable'), $field_array['name']);
                     }
                 }
             }
         }
         unset($opt_defaults);
         if ($field_array['custom_html'] == '') {
             $field_array['custom_html'] = FrmFieldsHelper::get_default_html($field_type);
         }
         if ($field_array['size'] == '') {
             $field_array['size'] = isset($frm_vars['sidebar_width']) ? $frm_vars['sidebar_width'] : '';
         }
         $field_array = apply_filters('frm_setup_edit_fields_vars', $field_array, $field, $values['id']);
         if (!isset($field_array['unique']) or !$field_array['unique']) {
             $field_array['unique_msg'] = '';
         }
         foreach ((array) $field->field_options as $k => $v) {
             if (!isset($field_array[$k])) {
                 $field_array[$k] = $v;
             }
             unset($k);
             unset($v);
         }
         $values['fields'][$field->id] = $field_array;
         unset($field);
     }
     $frm_form = new FrmForm();
     $form = $frm_form->getOne($table == 'entries' ? $record->form_id : $record->id);
     unset($frm_form);
     if ($form) {
         $values['form_name'] = isset($record->form_id) ? $form->name : '';
         if (is_array($form->options)) {
             foreach ($form->options as $opt => $value) {
                 if (in_array($opt, array('email_to', 'reply_to', 'reply_to_name'))) {
                     $values['notification'][0][$opt] = isset($post_values["notification[0][{$opt}]"]) ? maybe_unserialize($post_values["notification[0][{$opt}]"]) : $value;
                 }
                 $values[$opt] = isset($post_values[$opt]) ? maybe_unserialize($post_values[$opt]) : $value;
             }
         }
     }
     $form_defaults = FrmFormsHelper::get_default_opts();
     //set to posted value or default
     foreach ($form_defaults as $opt => $default) {
         if (!isset($values[$opt]) or $values[$opt] == '') {
             if ($opt == 'notification') {
                 $values[$opt] = ($post_values and isset($post_values[$opt])) ? $post_values[$opt] : $default;
                 foreach ($default as $o => $d) {
                     if ($o == 'email_to') {
                         $d = '';
                     }
                     //allow blank email address
                     $values[$opt][0][$o] = ($post_values and isset($post_values[$opt][0][$o])) ? $post_values[$opt][0][$o] : $d;
                     unset($o);
                     unset($d);
                 }
             } else {
                 $values[$opt] = ($post_values and isset($post_values['options'][$opt])) ? $post_values['options'][$opt] : $default;
             }
         } else {
             if ($values[$opt] == 'notification') {
                 foreach ($values[$opt] as $k => $n) {
                     foreach ($default as $o => $d) {
                         if (!isset($n[$o])) {
                             $values[$opt][$k][$o] = ($post_values and isset($post_values[$opt][$k][$o])) ? $post_values[$opt][$k][$o] : $d;
                         }
                         unset($o);
                         unset($d);
                     }
                     unset($k);
                     unset($n);
                 }
             }
         }
         unset($opt);
         unset($defaut);
     }
     if (!isset($values['custom_style'])) {
         $values['custom_style'] = ($post_values and isset($post_values['options']['custom_style'])) ? $_POST['options']['custom_style'] : $frm_settings->load_style != 'none';
     }
     foreach (array('before', 'after', 'submit') as $h) {
         if (!isset($values[$h . '_html'])) {
             $values[$h . '_html'] = isset($post_values['options'][$h . '_html']) ? $post_values['options'][$h . '_html'] : FrmFormsHelper::get_default_html($h);
         }
         unset($h);
     }
     if ($table == 'entries') {
         $values = FrmEntriesHelper::setup_edit_vars($values, $record);
     } else {
         if ($table == 'forms') {
             $values = FrmFormsHelper::setup_edit_vars($values, $record, $post_values);
         }
     }
     return $values;
 }
Ejemplo n.º 14
0
 public static function display_value($value, $field, $atts = array())
 {
     _deprecated_function(__FUNCTION__, '2.0', 'FrmEntriesHelper::display_value');
     return FrmEntriesHelper::display_value($value, $field, $atts);
 }
Ejemplo n.º 15
0
 public static function get_form_contents($form, $title, $description, $atts)
 {
     global $frm_vars;
     $frm_settings = FrmAppHelper::get_settings();
     $submit = isset($form->options['submit_value']) ? $form->options['submit_value'] : $frm_settings->submit_value;
     $user_ID = get_current_user_id();
     $params = FrmForm::get_params($form);
     $message = $errors = '';
     if ($params['posted_form_id'] == $form->id && $_POST) {
         $errors = isset($frm_vars['created_entries'][$form->id]) ? $frm_vars['created_entries'][$form->id]['errors'] : array();
     }
     $include_form_tag = apply_filters('frm_include_form_tag', true, $form);
     $fields = FrmFieldsHelper::get_form_fields($form->id, isset($errors) && !empty($errors));
     if ($params['action'] != 'create' || $params['posted_form_id'] != $form->id || !$_POST) {
         do_action('frm_display_form_action', $params, $fields, $form, $title, $description);
         if (apply_filters('frm_continue_to_new', true, $form->id, $params['action'])) {
             $values = FrmEntriesHelper::setup_new_vars($fields, $form);
             include FrmAppHelper::plugin_path() . '/classes/views/frm-entries/new.php';
         }
         return;
     }
     if (!empty($errors)) {
         $values = $fields ? FrmEntriesHelper::setup_new_vars($fields, $form) : array();
         include FrmAppHelper::plugin_path() . '/classes/views/frm-entries/new.php';
         return;
     }
     do_action('frm_validate_form_creation', $params, $fields, $form, $title, $description);
     if (!apply_filters('frm_continue_to_create', true, $form->id)) {
         return;
     }
     $values = FrmEntriesHelper::setup_new_vars($fields, $form, true);
     $created = isset($frm_vars['created_entries']) && isset($frm_vars['created_entries'][$form->id]) ? $frm_vars['created_entries'][$form->id]['entry_id'] : 0;
     $conf_method = apply_filters('frm_success_filter', 'message', $form, $form->options, 'create');
     if ($created && is_numeric($created) && $conf_method != 'message') {
         do_action('frm_success_action', $conf_method, $form, $form->options, $created);
         do_action('frm_after_entry_processed', array('entry_id' => $created, 'form' => $form));
         return;
     }
     if ($created && is_numeric($created)) {
         $message = isset($form->options['success_msg']) ? $form->options['success_msg'] : $frm_settings->success_msg;
         $class = 'frm_message';
     } else {
         $message = $frm_settings->failed_msg;
         $class = 'frm_error_style';
     }
     $message = FrmFormsHelper::get_success_message(array('message' => $message, 'form' => $form, 'entry_id' => $created, 'class' => $class));
     $message = apply_filters('frm_main_feedback', $message, $form, $created);
     if (!isset($form->options['show_form']) || $form->options['show_form']) {
         require FrmAppHelper::plugin_path() . '/classes/views/frm-entries/new.php';
     } else {
         global $frm_vars;
         self::maybe_load_css($form, $values['custom_style'], $frm_vars['load_css']);
         $include_extra_container = 'frm_forms' . FrmFormsHelper::get_form_style_class($values);
         include FrmAppHelper::plugin_path() . '/classes/views/frm-entries/errors.php';
     }
     do_action('frm_after_entry_processed', array('entry_id' => $created, 'form' => $form));
 }
Ejemplo n.º 16
0
 public static function get_form($form, $title, $description, $atts = array())
 {
     global $frm_field, $frm_entry, $frm_entry_meta, $frm_settings, $frm_vars;
     $form_name = $form->name;
     $frm_form = new FrmForm();
     $submit = isset($form->options['submit_value']) ? $form->options['submit_value'] : $frm_settings->submit_value;
     $saved_message = isset($form->options['success_msg']) ? $form->options['success_msg'] : $frm_settings->success_msg;
     $user_ID = get_current_user_id();
     $params = FrmEntriesController::get_params($form);
     $message = $errors = '';
     FrmEntriesHelper::enqueue_scripts($params);
     if ($params['posted_form_id'] == $form->id && $_POST) {
         $errors = isset($frm_vars['created_entries'][$form->id]) ? $frm_vars['created_entries'][$form->id]['errors'] : array();
     }
     $fields = FrmFieldsHelper::get_form_fields($form->id, isset($errors) && !empty($errors));
     $filename = FrmAppHelper::plugin_path() . '/classes/views/frm-entries/frm-entry.php';
     if (is_file($filename)) {
         ob_start();
         include $filename;
         $contents = ob_get_contents();
         ob_end_clean();
         // check if minimizing is turned on
         if (isset($atts['minimize']) && !empty($atts['minimize'])) {
             $contents = str_replace(array("\r\n", "\r", "\n", "\t", "    "), '', $contents);
         }
         return $contents;
     }
     return false;
 }
Ejemplo n.º 17
0
</h3>
                        <table class="form-table"><tbody>
                        <?php 
        $first_h3 = '';
    } else {
        ?>
                        <tr>
                            <th scope="row"><?php 
        echo esc_html($field->name);
        ?>
:</th>
                            <td>
                            <?php 
        $embedded_field_id = $entry->form_id != $field->form_id ? 'form' . $field->form_id : 0;
        $atts = array('type' => $field->type, 'post_id' => $entry->post_id, 'show_filename' => true, 'show_icon' => true, 'entry_id' => $entry->id, 'embedded_field_id' => $embedded_field_id);
        echo $display_value = FrmEntriesHelper::prepare_display_value($entry, $field, $atts);
        if (is_email($display_value) && !in_array($display_value, $to_emails)) {
            $to_emails[] = $display_value;
        }
        ?>
                            </td>
                        </tr>
                        <?php 
    }
}
?>

                        <?php 
if ($entry->parent_item_id) {
    ?>
                        <tr><th><?php 
Ejemplo n.º 18
0
        ?>
">
        <?php 
        if (in_array('id', $atts['fields'])) {
            ?>
            <td><?php 
            echo (int) $entry->id;
            ?>
</dh>
        <?php 
        }
        foreach ($atts['form_cols'] as $col) {
            ?>
            <td valign="top">
                <?php 
            echo FrmEntriesHelper::display_value(isset($entry->metas[$col->id]) ? $entry->metas[$col->id] : false, $col, array('type' => $col->type, 'post_id' => $entry->post_id, 'entry_id' => $entry->id));
            ?>
            </td>
<?php 
        }
        if ($atts['edit_link']) {
            ?>
			<td><?php 
            if (FrmProEntriesHelper::user_can_edit($entry, $atts['form'])) {
                ?>
<a href="<?php 
                echo esc_url(add_query_arg(array('frm_action' => 'edit', 'entry' => $entry->id), $atts['permalink']) . $atts['anchor']);
                ?>
"><?php 
                echo $atts['edit_link'];
                ?>
Ejemplo n.º 19
0
 /**
  * Get the options for a dependent Dynamic field
  *
  * @since 2.0.16
  * @param array $args
  * @param array $field
  */
 private static function get_dependent_dynamic_field_options($args, &$field)
 {
     $linked_field = FrmField::getOne($args['linked_field_id']);
     $field['options'] = array();
     $metas = array();
     FrmProEntryMetaHelper::meta_through_join($args['trigger_field_id'], $linked_field, $args['entry_id'], $args['field_data'], $metas);
     $metas = stripslashes_deep($metas);
     if (FrmProFieldsHelper::include_blank_option($metas, $args['field_data'])) {
         $field['options'][''] = '';
     }
     foreach ($metas as $meta) {
         $field['options'][$meta->item_id] = FrmEntriesHelper::display_value($meta->meta_value, $linked_field, array('type' => $linked_field->type, 'show_icon' => true, 'show_filename' => false));
         unset($meta);
     }
     // change the form_select value so the filter doesn't override the values
     $args['field_data']->field_options['form_select'] = 'filtered_' . $args['field_data']->field_options['form_select'];
     $field = apply_filters('frm_setup_new_fields_vars', $field, $args['field_data']);
     // Sort the options
     $field['options'] = apply_filters('frm_data_sort', $field['options'], array('metas' => $metas, 'field' => $args['linked_field_id']));
 }
Ejemplo n.º 20
0
 function validate($params, $fields, $form, $title, $description)
 {
     global $frm_entry, $frm_settings, $frm_vars;
     if (($_POST and isset($_POST['frm_page_order_' . $form->id]) or FrmProFormsHelper::going_to_prev($form->id)) and !FrmProFormsHelper::saving_draft($form->id)) {
         $errors = '';
         $fields = FrmFieldsHelper::get_form_fields($form->id);
         $form_name = $form->name;
         $submit = isset($form->options['submit_value']) ? $form->options['submit_value'] : $frm_settings->submit_value;
         $values = $fields ? FrmEntriesHelper::setup_new_vars($fields, $form) : array();
         require FrmAppHelper::plugin_path() . '/classes/views/frm-entries/new.php';
         add_filter('frm_continue_to_create', '__return_false');
     } else {
         if ($form->editable and isset($form->options['single_entry']) and $form->options['single_entry'] and $form->options['single_entry_type'] == 'user') {
             $user_ID = get_current_user_id();
             if ($user_ID) {
                 $entry = $frm_entry->getAll(array('it.user_id' => $user_ID, 'it.form_id' => $form->id), '', 1, true);
                 if ($entry) {
                     $entry = reset($entry);
                 }
             } else {
                 $entry = false;
             }
             if ($entry and !empty($entry) and (!isset($frm_vars['created_entries'][$form->id]) or !isset($frm_vars['created_entries'][$form->id]['entry_id']) or $entry->id != $frm_vars['created_entries'][$form->id]['entry_id'])) {
                 FrmProEntriesController::show_responses($entry, $fields, $form, $title, $description);
             } else {
                 $record = $frm_vars['created_entries'][$form->id]['entry_id'];
                 $saved_message = isset($form->options['success_msg']) ? $form->options['success_msg'] : $frm_settings->success_msg;
                 if (FrmProFormsHelper::saving_draft($form->id)) {
                     global $frmpro_settings;
                     $saved_message = isset($form->options['draft_msg']) ? $form->options['draft_msg'] : $frmpro_settings->draft_msg;
                 }
                 $saved_message = apply_filters('frm_content', $saved_message, $form, $record ? $record : false);
                 $message = wpautop(do_shortcode($record ? $saved_message : $frm_settings->failed_msg));
                 $message = '<div class="frm_message" id="message">' . $message . '</div>';
                 FrmProEntriesController::show_responses($record, $fields, $form, $title, $description, $message, '', $form->options);
             }
             add_filter('frm_continue_to_create', '__return_false');
         } else {
             if (FrmProFormsHelper::saving_draft($form->id)) {
                 global $frmpro_settings;
                 $record = (isset($frm_vars['created_entries']) and isset($frm_vars['created_entries'][$form->id])) ? $frm_vars['created_entries'][$form->id]['entry_id'] : 0;
                 if ($record) {
                     $saved_message = isset($form->options['draft_msg']) ? $form->options['draft_msg'] : $frmpro_settings->draft_msg;
                     $saved_message = apply_filters('frm_content', $saved_message, $form, $record);
                     $message = '<div class="frm_message" id="message">' . wpautop(do_shortcode($saved_message)) . '</div>';
                     FrmProEntriesController::show_responses($record, $fields, $form, $title, $description, $message, '', $form->options);
                     add_filter('frm_continue_to_create', '__return_false');
                 }
             }
         }
     }
 }
Ejemplo n.º 21
0
 public static function validate_check_confirmation_field(&$errors, $field, $value, $args)
 {
     $conf_val = '';
     // Temporarily swtich $field->id in order to get and set the value posted in confirmation field
     $field_id = $field->id;
     $field->id = 'conf_' . $field_id;
     FrmEntriesHelper::get_posted_value($field, $conf_val, $args);
     // Switch $field->id back to original id
     $field->id = $field_id;
     unset($field_id);
     //If editing entry or if user hits Next/Submit on a draft
     if ($args['action'] == 'update') {
         //If in repeating section
         if (isset($args['key_pointer']) && ($args['key_pointer'] || $args['key_pointer'] === 0)) {
             $entry_id = str_replace('i', '', $args['key_pointer']);
         } else {
             $entry_id = $_POST && isset($_POST['id']) ? $_POST['id'] : false;
         }
         $prev_value = FrmEntryMeta::get_entry_meta_by_field($entry_id, $field->id);
         if ($prev_value != $value && $conf_val != $value) {
             $errors['conf_field' . $field->temp_id] = isset($field->field_options['conf_msg']) ? $field->field_options['conf_msg'] : __('The entered values do not match', 'formidable');
             $errors['field' . $field->temp_id] = '';
         }
     } else {
         if ($args['action'] == 'create' && $conf_val != $value) {
             //If creating entry
             $errors['conf_field' . $field->temp_id] = isset($field->field_options['conf_msg']) ? $field->field_options['conf_msg'] : __('The entered values do not match', 'formidable');
             $errors['field' . $field->temp_id] = '';
         }
     }
 }
 function get_entry_select()
 {
     echo FrmEntriesHelper::entries_dropdown($_POST['form_id'], 'entry_id');
     die;
 }
Ejemplo n.º 23
0
 function validate($params, $fields, $form, $title, $description)
 {
     global $user_ID, $frm_entry_meta, $frm_entry, $frm_settings, $frmpro_settings, $frmpro_entries_controller, $frmdb;
     $form_options = stripslashes_deep(maybe_unserialize($form->options));
     $can_submit = true;
     if (isset($form_options['single_entry']) and $form_options['single_entry']) {
         if ($form_options['single_entry_type'] == 'cookie' and isset($_COOKIE['frm_form' . $form->id . '_' . COOKIEHASH])) {
             $can_submit = false;
         } else {
             if ($form_options['single_entry_type'] == 'ip') {
                 $prev_entry = $frm_entry->getAll(array('it.ip' => $_SERVER['REMOTE_ADDR']), '', 1);
                 if ($prev_entry) {
                     $can_submit = false;
                 }
             } else {
                 if ($form_options['single_entry_type'] == 'user' and !$form->editable) {
                     $meta = $frmdb->get_var($frmdb->entries, array('user_id' => $user_ID, 'form_id' => $form->id));
                     if ($meta) {
                         $can_submit = false;
                     }
                 } else {
                     if (is_numeric($form_options['single_entry_type'])) {
                         $field_id = $form_options['single_entry_type'];
                         $meta = $frm_entry_meta->getAll("meta_value='" . $_POST['item_meta'][$field_id] . "' and fi.id='{$field_id}' and fi.form_id='{$form->id}'", '', ' LIMIT 1');
                         if ($meta) {
                             $can_submit = false;
                         }
                     }
                 }
             }
         }
         if (!$can_submit) {
             echo stripslashes($frmpro_settings->already_submitted);
             //TODO: DO SOMETHING IF USER CANNOT RESUBMIT FORM
             add_filter('frm_continue_to_create', create_function('', 'return false;'));
             return;
         }
     }
     if (isset($_POST) and isset($_POST['frm_page_order_' . $form->id])) {
         global $frm_next_page;
         $errors = '';
         $fields = FrmFieldsHelper::get_form_fields($form->id);
         $form_name = $form->name;
         $submit = isset($form_options['submit_value']) ? $form_options['submit_value'] : $frm_settings->submit_value;
         $values = FrmEntriesHelper::setup_new_vars($fields, $form);
         require FRM_VIEWS_PATH . '/frm-entries/new.php';
         add_filter('frm_continue_to_create', create_function('', 'return false;'));
     } else {
         if ($form->editable and isset($form_options['single_entry']) and $form_options['single_entry']) {
             $saved_message = isset($form_options['success_msg']) ? $form_options['success_msg'] : $frm_settings->success_msg;
             $entry = $frm_entry->getAll(array('it.user_id' => $user_ID, 'it.form_id' => $form->id), '', 1, true);
             if ($entry and !empty($entry)) {
                 $message = stripslashes($frmpro_settings->already_submitted);
                 $frmpro_entries_controller->show_responses(reset($entry), $fields, $form, $title, $description, $message);
             } else {
                 $record = $frm_entry->create($_POST);
                 $message = $record ? $saved_message : $frm_settings->failed_msg;
                 $frmpro_entries_controller->show_responses($record, $fields, $form, $title, $description, $message, '', $form_options);
             }
             add_filter('frm_continue_to_create', create_function('', 'return false;'));
         }
     }
 }
Ejemplo n.º 24
0
 public static function trigger_email($action, $entry, $form)
 {
     if (defined('WP_IMPORTING') && WP_IMPORTING) {
         return;
     }
     global $wpdb;
     $notification = $action->post_content;
     $email_key = $action->ID;
     // Set the subject
     if (empty($notification['email_subject'])) {
         $notification['email_subject'] = sprintf(__('%1$s Form submitted on %2$s', 'formidable'), $form->name, '[sitename]');
     }
     $plain_text = $notification['plain_text'] ? true : false;
     //Filter these fields
     $filter_fields = array('email_to', 'cc', 'bcc', 'reply_to', 'from', 'email_subject', 'email_message');
     add_filter('frm_plain_text_email', $plain_text ? '__return_true' : '__return_false');
     //Get all values in entry in order to get User ID field ID
     $values = FrmEntryMeta::getAll(array('it.field_id !' => 0, 'it.item_id' => $entry->id), ' ORDER BY fi.field_order');
     $user_id_field = $user_id_key = '';
     foreach ($values as $value) {
         if ($value->field_type == 'user_id') {
             $user_id_field = $value->field_id;
             $user_id_key = $value->field_key;
             break;
         }
         unset($value);
     }
     //Filter and prepare the email fields
     foreach ($filter_fields as $f) {
         //Don't allow empty From
         if ($f == 'from' && empty($notification[$f])) {
             $notification[$f] = '[admin_email]';
         } else {
             if (in_array($f, array('email_to', 'cc', 'bcc', 'reply_to', 'from'))) {
                 //Remove brackets
                 //Add a space in case there isn't one
                 $notification[$f] = str_replace('<', ' ', $notification[$f]);
                 $notification[$f] = str_replace(array('"', '>'), '', $notification[$f]);
                 //Switch userID shortcode to email address
                 if (strpos($notification[$f], '[' . $user_id_field . ']') !== false || strpos($notification[$f], '[' . $user_id_key . ']') !== false) {
                     $user_data = get_userdata($entry->metas[$user_id_field]);
                     $user_email = $user_data->user_email;
                     $notification[$f] = str_replace(array('[' . $user_id_field . ']', '[' . $user_id_key . ']'), $user_email, $notification[$f]);
                 }
             }
         }
         $notification[$f] = FrmFieldsHelper::basic_replace_shortcodes($notification[$f], $form, $entry);
     }
     //Put recipients, cc, and bcc into an array if they aren't empty
     $to_emails = self::explode_emails($notification['email_to']);
     $cc = self::explode_emails($notification['cc']);
     $bcc = self::explode_emails($notification['bcc']);
     $to_emails = apply_filters('frm_to_email', $to_emails, $values, $form->id, compact('email_key', 'entry', 'form'));
     // Stop now if there aren't any recipients
     if (empty($to_emails) && empty($cc) && empty($bcc)) {
         return;
     }
     $to_emails = array_unique((array) $to_emails);
     $prev_mail_body = $mail_body = $notification['email_message'];
     $mail_body = FrmEntriesHelper::replace_default_message($mail_body, array('id' => $entry->id, 'entry' => $entry, 'plain_text' => $plain_text, 'user_info' => isset($notification['inc_user_info']) ? $notification['inc_user_info'] : false));
     // Add the user info if it isn't already included
     if ($notification['inc_user_info'] && $prev_mail_body == $mail_body) {
         $data = maybe_unserialize($entry->description);
         $mail_body .= "\r\n\r\n" . __('User Information', 'formidable') . "\r\n";
         $mail_body .= __('IP Address', 'formidable') . ': ' . $entry->ip . "\r\n";
         $mail_body .= __('User-Agent (Browser/OS)', 'formidable') . ': ' . FrmEntryFormat::get_browser($data['browser']) . "\r\n";
         $mail_body .= __('Referrer', 'formidable') . ': ' . $data['referrer'] . "\r\n";
     }
     unset($prev_mail_body);
     // Add attachments
     $attachments = apply_filters('frm_notification_attachment', array(), $form, compact('entry', 'email_key'));
     if (!empty($notification['email_subject'])) {
         $notification['email_subject'] = apply_filters('frm_email_subject', $notification['email_subject'], compact('form', 'entry', 'email_key'));
     }
     // check for a phone number
     foreach ((array) $to_emails as $email_key => $e) {
         if ($e != '[admin_email]' && !is_email($e)) {
             $e = explode(' ', $e);
             //If to_email has name <*****@*****.**> format
             if (is_email(end($e))) {
                 continue;
             }
             do_action('frm_send_to_not_email', array('e' => $e, 'subject' => $notification['email_subject'], 'mail_body' => $mail_body, 'reply_to' => $notification['reply_to'], 'from' => $notification['from'], 'plain_text' => $plain_text, 'attachments' => $attachments, 'form' => $form, 'email_key' => $email_key));
             unset($to_emails[$email_key]);
         }
     }
     // Send the email now
     $sent_to = self::send_email(array('to_email' => $to_emails, 'subject' => $notification['email_subject'], 'message' => $mail_body, 'from' => $notification['from'], 'plain_text' => $plain_text, 'reply_to' => $notification['reply_to'], 'attachments' => $attachments, 'cc' => $cc, 'bcc' => $bcc));
     return $sent_to;
 }
Ejemplo n.º 25
0
 public static function get_new_vars($errors = array(), $form = false, $message = '')
 {
     global $frm_field, $frm_entry, $frm_settings, $frm_vars;
     $description = true;
     $title = false;
     $form = apply_filters('frm_pre_display_form', $form);
     $fields = FrmFieldsHelper::get_form_fields($form->id, !empty($errors));
     $values = $fields ? FrmEntriesHelper::setup_new_vars($fields, $form) : array();
     $submit = isset($frm_vars['next_page'][$form->id]) ? $frm_vars['next_page'][$form->id] : (isset($values['submit_value']) ? $values['submit_value'] : $frm_settings->submit_value);
     if (is_object($submit)) {
         $submit = $submit->name;
     }
     require FrmAppHelper::plugin_path() . '/pro/classes/views/frmpro-entries/new.php';
 }
Ejemplo n.º 26
0
            if ($values['custom_style']) {
                $frm_vars['load_css'] = true;
            }
            if ((!isset($frm_vars['css_loaded']) || !$frm_vars['css_loaded']) && $frm_vars['load_css']) {
                echo FrmAppController::footer_js('header');
                $frm_vars['css_loaded'] = true;
            }
            ?>
<div class="frm_forms<?php 
            echo $values['custom_style'] ? ' with_frm_style' : '';
            ?>
" id="frm_form_<?php 
            echo $form->id;
            ?>
_container"><?php 
            require FrmAppHelper::plugin_path() . '/classes/views/frm-entries/errors.php';
            ?>
</div>
<?php 
        }
    } else {
        do_action('frm_success_action', $conf_method, $form, $form->options, $created);
    }
    do_action('frm_after_entry_processed', array('entry_id' => $created, 'form' => $form));
} else {
    do_action('frm_display_form_action', $params, $fields, $form, $title, $description);
    if (apply_filters('frm_continue_to_new', true, $form->id, $params['action'])) {
        $values = FrmEntriesHelper::setup_new_vars($fields, $form);
        require FrmAppHelper::plugin_path() . '/classes/views/frm-entries/new.php';
    }
}
Ejemplo n.º 27
0
 public static function get_field_value_shortcode($sc_atts)
 {
     $atts = shortcode_atts(array('entry' => false, 'field_id' => false, 'user_id' => false, 'ip' => false, 'show' => '', 'format' => '', 'return_array' => false, 'default' => ''), $sc_atts);
     // Include all user-defined atts as well
     $atts = (array) $atts + (array) $sc_atts;
     // For reverse compatibility
     if (isset($atts['entry_id']) && !$atts['entry']) {
         $atts['entry'] = $atts['entry_id'];
     }
     if (!$atts['field_id']) {
         return __('You are missing options in your shortcode. field_id is required.', 'formidable');
     }
     $field = FrmField::getOne($atts['field_id']);
     if (!$field) {
         return $atts['default'];
     }
     $entry = self::get_frm_field_value_entry($field, $atts);
     if (!$entry) {
         return $atts['default'];
     }
     $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 ($field->type == 'file' && !isset($atts['html'])) {
         // default to show the image instead of the url
         $atts['html'] = 1;
     }
     if (!empty($atts['format']) || isset($atts['show']) && !empty($atts['show'])) {
         $value = FrmFieldsHelper::get_display_value($value, $field, $atts);
     } else {
         $value = FrmEntriesHelper::display_value($value, $field, $atts);
     }
     return $value;
 }
Ejemplo n.º 28
0
 /**
  * Editing a Form or Entry
  * @param string $table
  * @return bool|array
  */
 public static function setup_edit_vars($record, $table, $fields = '', $default = false, $post_values = array())
 {
     if (!$record) {
         return false;
     }
     global $frm_vars;
     if (empty($post_values)) {
         $post_values = stripslashes_deep($_POST);
     }
     $values = array('id' => $record->id, 'fields' => array());
     foreach (array('name', 'description') as $var) {
         $default_val = isset($record->{$var}) ? $record->{$var} : '';
         $values[$var] = self::get_param($var, $default_val);
         unset($var, $default_val);
     }
     $values['description'] = self::use_wpautop($values['description']);
     $frm_settings = self::get_settings();
     $is_form_builder = self::is_admin_page('formidable');
     foreach ((array) $fields as $field) {
         // Make sure to filter default values (for placeholder text), but not on the form builder page
         if (!$is_form_builder) {
             $field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true);
         }
         self::fill_field_defaults($field, $record, $values, compact('default', 'post_values', 'frm_settings'));
     }
     self::fill_form_opts($record, $table, $post_values, $values);
     if ($table == 'entries') {
         $values = FrmEntriesHelper::setup_edit_vars($values, $record);
     } else {
         if ($table == 'forms') {
             $values = FrmFormsHelper::setup_edit_vars($values, $record, $post_values);
         }
     }
     return $values;
 }
Ejemplo n.º 29
0
 public static function replace_html_shortcodes($html, $field, $atts)
 {
     if ('divider' == $field['type']) {
         global $frm_vars;
         $html = str_replace(array('frm_none_container', 'frm_hidden_container', 'frm_top_container', 'frm_left_container', 'frm_right_container'), '', $html);
         if (isset($frm_vars['collapse_div']) && $frm_vars['collapse_div']) {
             $html = "</div>\n" . $html;
             $frm_vars['collapse_div'] = false;
         }
         if (isset($frm_vars['div']) && $frm_vars['div'] && $frm_vars['div'] != $field['id']) {
             // close the div if it's from a different section
             $html = "</div>\n" . $html;
             $frm_vars['div'] = false;
         }
         if (FrmField::is_option_true($field, 'slide')) {
             $trigger = ' frm_trigger';
             $collapse_div = '<div class="frm_toggle_container" style="display:none;">';
         } else {
             $trigger = $collapse_div = '';
         }
         if (FrmField::is_option_true($field, 'repeat')) {
             $errors = isset($atts['errors']) ? $atts['errors'] : array();
             $field_name = 'item_meta[' . $field['id'] . ']';
             $html_id = FrmFieldsHelper::get_html_id($field);
             $frm_settings = FrmAppHelper::get_settings();
             ob_start();
             include FrmAppHelper::plugin_path() . '/classes/views/frm-fields/input.php';
             $input = ob_get_contents();
             ob_end_clean();
             if (FrmField::is_option_true($field, 'slide')) {
                 $input = $collapse_div . $input . '</div>';
             }
             $html = str_replace('[collapse_this]', $input, $html);
         } else {
             self::remove_close_div($field, $html);
             if (strpos($html, '[collapse_this]') !== false) {
                 $html = str_replace('[collapse_this]', $collapse_div, $html);
                 // indicate that a second div is open
                 if (!empty($collapse_div)) {
                     $frm_vars['collapse_div'] = $field['id'];
                 }
             }
         }
         self::maybe_add_collapse_icon($trigger, $field, $html);
         $html = str_replace('[collapse_class]', $trigger, $html);
     } else {
         if ($field['type'] == 'html') {
             if (apply_filters('frm_use_wpautop', true)) {
                 $html = wpautop($html);
             }
             $html = apply_filters('frm_get_default_value', $html, (object) $field, false);
             $html = do_shortcode($html);
         } else {
             if (FrmField::is_option_true($field, 'conf_field')) {
                 //Add confirmation field
                 //Get confirmation field ready for replace_shortcodes function
                 $conf_html = $field['custom_html'];
                 $conf_field = $field;
                 $conf_field['id'] = 'conf_' . $field['id'];
                 $conf_field['name'] = __('Confirm', 'formidable') . ' ' . $field['name'];
                 $conf_field['description'] = $field['conf_desc'];
                 $conf_field['field_key'] = 'conf_' . $field['field_key'];
                 if ($conf_field['classes']) {
                     $conf_field['classes'] = str_replace('first_', '', $conf_field['classes']);
                 } else {
                     if ($conf_field['conf_field'] == 'inline') {
                         $conf_field['classes'] = ' frm_half';
                     }
                 }
                 //Prevent loop
                 $conf_field['conf_field'] = 'stop';
                 //If inside of repeating section
                 $args = array();
                 if (isset($atts['section_id'])) {
                     $args['field_name'] = preg_replace('/\\[' . $field['id'] . '\\]$/', '', $atts['field_name']);
                     $args['field_name'] = $args['field_name'] . '[conf_' . $field['id'] . ']';
                     $args['field_id'] = 'conf_' . $atts['field_id'];
                     $args['field_plus_id'] = $atts['field_plus_id'];
                     $args['section_id'] = $atts['section_id'];
                 }
                 // Filter default value/placeholder text
                 $field['conf_input'] = apply_filters('frm_get_default_value', $field['conf_input'], (object) $field, false);
                 //If clear on focus, set default value. Otherwise, set value.
                 if ($conf_field['clear_on_focus'] == 1) {
                     $conf_field['default_value'] = $field['conf_input'];
                     $conf_field['value'] = '';
                 } else {
                     $conf_field['value'] = $field['conf_input'];
                 }
                 //If going back and forth between pages, keep value in confirmation field
                 if (isset($_POST['item_meta'])) {
                     $temp_args = array();
                     if (isset($atts['section_id'])) {
                         $temp_args = array('parent_field_id' => $atts['section_id'], 'key_pointer' => str_replace('-', '', $atts['field_plus_id']));
                     }
                     FrmEntriesHelper::get_posted_value($conf_field['id'], $conf_field['value'], $temp_args);
                 }
                 //Replace shortcodes
                 $conf_html = FrmFieldsHelper::replace_shortcodes($conf_html, $conf_field, '', '', $args);
                 //Add a couple of classes
                 $conf_html = str_replace('frm_primary_label', 'frm_primary_label frm_conf_label', $conf_html);
                 $conf_html = str_replace('frm_form_field', 'frm_form_field frm_conf_field', $conf_html);
                 //Remove label if stacked. Hide if inline.
                 if ($field['conf_field'] == 'inline') {
                     $conf_html = str_replace('frm_form_field', 'frm_form_field frm_hidden_container', $conf_html);
                 } else {
                     $conf_html = str_replace('frm_form_field', 'frm_form_field frm_none_container', $conf_html);
                 }
                 $html .= $conf_html;
             }
         }
     }
     if (strpos($html, '[collapse_this]')) {
         $html = str_replace('[collapse_this]', '', $html);
     }
     return $html;
 }