Example #1
0
 function prepare_items()
 {
     global $wpdb, $per_page, $frm_settings;
     $paged = $this->get_pagenum();
     $default_orderby = 'name';
     $default_order = 'ASC';
     $orderby = isset($_REQUEST['orderby']) ? $_REQUEST['orderby'] : $default_orderby;
     $order = isset($_REQUEST['order']) ? $_REQUEST['order'] : $default_order;
     $page = $this->get_pagenum();
     $default_count = empty($this->page_name) ? 20 : 10;
     $per_page = $this->get_items_per_page('formidable_page_formidable' . str_replace('-', '_', $this->page_name) . '_per_page', $default_count);
     $start = isset($_REQUEST['start']) ? $_REQUEST['start'] : ($page - 1) * $per_page;
     $s = isset($_REQUEST['s']) ? stripslashes($_REQUEST['s']) : '';
     $fid = isset($_REQUEST['fid']) ? $_REQUEST['fid'] : '';
     if ($s != '') {
         preg_match_all('/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $s, $matches);
         $search_terms = array_map('trim', $matches[0]);
     }
     $s_query = " (status is NULL OR status = '' OR status = 'published') AND default_template=0 AND is_template = " . (int) $this->params['template'];
     if ($s != '') {
         foreach ((array) $search_terms as $term) {
             if (!empty($s_query)) {
                 $s_query .= " AND";
             }
             $term = FrmAppHelper::esc_like($term);
             $s_query .= $wpdb->prepare(" (name like %s OR description like %s OR created_at like %s)", '%' . $term . '%', '%' . $term . '%', '%' . $term . '%');
             unset($term);
         }
     }
     $frm_form = new FrmForm();
     $this->items = $frm_form->getAll($s_query, " ORDER BY {$orderby} {$order}", " LIMIT {$start}, {$per_page}", true, false);
     $total_items = FrmAppHelper::getRecordCount($s_query, $this->table_name);
     $this->set_pagination_args(array('total_items' => $total_items, 'per_page' => $per_page));
 }
Example #2
0
 function duplicate($id, $template = false, $copy_keys = false, $blog_id = false)
 {
     global $wpdb;
     $frm_form = new FrmForm();
     $values = $frm_form->getOne($id, $blog_id);
     if (!$values) {
         return false;
     }
     $new_key = $copy_keys ? $values->form_key : '';
     $new_values = array('form_key' => FrmAppHelper::get_unique_key($new_key, $wpdb->prefix . 'frm_forms', 'form_key'), 'name' => $values->name, 'description' => $values->description, 'status' => $template ? '' : 'draft', 'logged_in' => $values->logged_in ? $values->logged_in : 0, 'editable' => $values->editable ? $values->editable : 0, 'created_at' => current_time('mysql', 1), 'is_template' => $template ? 1 : 0);
     if ($blog_id) {
         $new_values['status'] = 'published';
         $new_options = maybe_unserialize($values->options);
         $new_options['email_to'] = get_option('admin_email');
         $new_options['copy'] = false;
         $new_values['options'] = $new_options;
     } else {
         $new_values['options'] = $values->options;
     }
     if (is_array($new_values['options'])) {
         $new_values['options'] = serialize($new_values['options']);
     }
     $query_results = $wpdb->insert($wpdb->prefix . 'frm_forms', $new_values);
     if ($query_results) {
         global $frm_field;
         $form_id = $wpdb->insert_id;
         $frm_field->duplicate($id, $form_id, $copy_keys, $blog_id);
         // update form settings after fields are created
         do_action('frm_after_duplicate_form', $form_id, $new_values);
         return $form_id;
     } else {
         return false;
     }
 }
 function test_create_form()
 {
     FrmAppController::install();
     $frm_form = new FrmForm();
     $values = FrmFormsHelper::setup_new_vars(false);
     $id = $frm_form->create($values);
     $this->assertGreaterThan(0, $id);
 }
 private function get_forms()
 {
     $forms = array();
     $formidable = new FrmForm();
     foreach ($formidable->get_published_forms() as $form) {
         $forms[$form->name] = $form->id;
     }
     return $forms;
 }
Example #5
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);
     }
 }
Example #6
0
 public static function form($errors = array(), $message = '')
 {
     //wp_enqueue_script('jquery-chosen');
     //wp_enqueue_style('formidable');
     $frm_form = new FrmForm();
     $forms = $frm_form->getAll("status is NULL OR status = '' OR status = 'published'", ' ORDER BY name');
     unset($frm_form);
     $export_types = apply_filters('frm_xml_export_types', array('forms' => __('Forms', 'formidable')));
     $export_format = apply_filters('frm_export_formats', array('xml' => array('name' => 'XML', 'support' => 'forms', 'count' => 'multiple')));
     global $frmpro_settings;
     $csv_format = $frmpro_settings ? $frmpro_settings->csv_format : 'UTF-8';
     include FrmAppHelper::plugin_path() . '/classes/views/xml/import_form.php';
 }
 function _setup_test_update_values($entry)
 {
     $form = FrmForm::getOne($entry->form_id);
     $this->set_current_user_to_1();
     $values = array('form_id' => $entry->form_id, 'frm_hide_fields_' . $entry->form_id => '', 'frm_helers_' . $entry->form_id => '', 'form_key' => $form->form_key, 'item_meta' => $entry->metas, 'frm_submit_entry_' . $entry->form_id => wp_create_nonce('frm_submit_entry_' . $entry->form_id), '_wp_http_referer' => '/features/create-a-post-no-categories/?frm_action=edit&entry=' . $entry->id, 'id' => $entry->id, 'item_key' => $entry->item_key, 'item_name' => $entry->name, 'frm_user_id' => $entry->user_id, 'frm_skip_cookie' => 1);
     return $values;
 }
 public static function show()
 {
     FrmAppHelper::permission_check('frm_view_reports');
     remove_action('frm_form_action_reports', 'FrmStatisticsController::list_reports');
     add_filter('frm_form_stop_action_reports', '__return_true');
     global $wpdb;
     $form = false;
     if (isset($_REQUEST['form'])) {
         $form = FrmForm::getOne($_REQUEST['form']);
     }
     if (!$form) {
         require FrmAppHelper::plugin_path() . '/pro/classes/views/frmpro-statistics/select.php';
         return;
     }
     $exclude_types = FrmField::no_save_fields();
     $exclude_types = array_merge($exclude_types, array('rte', 'textarea', 'file', 'grid', 'signature', 'form', 'table'));
     $fields = FrmField::getAll(array('fi.form_id' => (int) $form->id, 'fi.type not' => $exclude_types), 'field_order');
     $js = '';
     $data = array();
     $colors = '#21759B,#EF8C08,#C6C6C6';
     $data['time'] = self::get_daily_entries($form, array('is3d' => true, 'colors' => $colors, 'bg_color' => 'transparent'));
     $data['month'] = self::get_daily_entries($form, array('is3d' => true, 'colors' => $colors, 'bg_color' => 'transparent', 'width' => '100%'), 'MONTH');
     foreach ($fields as $field) {
         $this_data = self::graph_shortcode(array('id' => $field->id, 'field' => $field, 'is3d' => true, 'min' => 0, 'colors' => $colors, 'width' => 650, 'bg_color' => 'transparent'));
         if (strpos($this_data, 'frm_no_data_graph') === false) {
             $data[$field->id] = $this_data;
         }
         unset($field, $this_data);
     }
     $entries = FrmDb::get_col($wpdb->prefix . 'frm_items', array('form_id' => $form->id), 'created_at');
     // trigger the scripts to load
     global $frm_vars;
     $frm_vars['forms_loaded'][] = true;
     include FrmAppHelper::plugin_path() . '/pro/classes/views/frmpro-statistics/show.php';
 }
 public static function setup_edit_vars($record, $doing_ajax = false)
 {
     $values = array('id' => $record->id, 'form_id' => $record->form_id);
     $defaults = array('name' => $record->name, 'description' => $record->description, 'field_key' => $record->field_key, 'type' => $record->type, 'default_value' => $record->default_value, 'field_order' => $record->field_order, 'required' => $record->required);
     if ($doing_ajax) {
         $values = $values + $defaults;
         $values['form_name'] = '';
     } else {
         foreach ($defaults as $var => $default) {
             $values[$var] = FrmAppHelper::get_param($var, $default, 'get', 'htmlspecialchars');
             unset($var, $default);
         }
         $values['form_name'] = $record->form_id ? FrmForm::getName($record->form_id) : '';
     }
     unset($defaults);
     $values['options'] = $record->options;
     $values['field_options'] = $record->field_options;
     $defaults = self::get_default_field_opts($values['type'], $record, true);
     if ($values['type'] == 'captcha') {
         $frm_settings = FrmAppHelper::get_settings();
         $defaults['invalid'] = $frm_settings->re_msg;
     }
     foreach ($defaults as $opt => $default) {
         $values[$opt] = isset($record->field_options[$opt]) ? $record->field_options[$opt] : $default;
         unset($opt, $default);
     }
     $values['custom_html'] = isset($record->field_options['custom_html']) ? $record->field_options['custom_html'] : self::get_default_html($record->type);
     return apply_filters('frm_setup_edit_field_vars', $values, array('doing_ajax' => $doing_ajax));
 }
 public static function add_form_nav($views)
 {
     if (!FrmProDisplaysHelper::is_edit_view_page()) {
         return $views;
     }
     $form = isset($_REQUEST['form']) && is_numeric($_REQUEST['form']) ? $_REQUEST['form'] : false;
     if (!$form) {
         return $views;
     }
     $form = FrmForm::getOne($form);
     if (!$form) {
         return $views;
     }
     echo '<div id="poststuff">';
     echo '<div id="post-body" class="metabox-holder columns-2">';
     echo '<div id="post-body-content">';
     FrmAppController::get_form_nav($form, true, 'hide');
     echo '</div>';
     echo '<div class="clear"></div>';
     echo '</div>';
     echo '<div id="titlediv"><input id="title" type="text" value="' . esc_attr($form->name == '' ? __('(no title)') : $form->name) . '" readonly="readonly" disabled="disabled" /></div>';
     echo '</div>';
     echo '<style type="text/css">p.search-box{margin-top:-91px;}</style>';
     return $views;
 }
 function user_can_edit_check($entry, $form)
 {
     global $user_ID;
     if (!$user_ID) {
         return false;
     }
     if (is_numeric($form)) {
         $form = FrmForm::getOne($form);
     }
     $form->options = maybe_unserialize($form->options);
     //if editable and user can edit someone elses entry
     if ($form->editable and isset($form->options['open_editable']) and $form->options['open_editable'] and isset($form->options['open_editable_role']) and FrmAppHelper::user_has_permission($form->options['open_editable_role'])) {
         return true;
     }
     if (is_object($entry)) {
         if ($entry->user_id == $user_ID) {
             return true;
         } else {
             return false;
         }
     }
     $where = "user_id='{$user_ID}' and fr.id='{$form->id}'";
     if ($entry and !empty($entry)) {
         if (is_numeric($entry)) {
             $where .= ' and it.id=' . $entry;
         } else {
             $where .= " and item_key='" . $entry . "'";
         }
     }
     return FrmEntry::getAll($where, '', ' LIMIT 1', true);
 }
 /**
  * @covers FrmXMLHelper::track_repeating_fields
  * @covers FrmXMLHelper::update_repeat_field_options
  */
 public function _check_form_select($f, $expected_form_key)
 {
     $this->assertNotEmpty($f->field_options['form_select'], 'Imported repeating section has a blank form_select.');
     // Check if the form_select setting matches the correct form
     $nested_form = FrmForm::getOne($f->field_options['form_select']);
     $this->assertNotEmpty($nested_form, 'The form_select in an imported repeating section is not updating correctly.');
     $this->assertEquals($expected_form_key, $nested_form->form_key, 'The form_select is not updating properly when a repeating section is imported.');
 }
Example #13
0
 public static function get_form_nav($id, $show_nav = false)
 {
     global $pagenow, $frm_vars;
     $show_nav = FrmAppHelper::get_param('show_nav', $show_nav);
     if (!$show_nav) {
         return;
     }
     $current_page = isset($_GET['page']) ? $_GET['page'] : (isset($_GET['post_type']) ? $_GET['post_type'] : 'None');
     if ($id and is_numeric($id)) {
         $frm_form = new FrmForm();
         $form = $frm_form->getOne($id);
         unset($frm_form);
     } else {
         $form = false;
     }
     include FrmAppHelper::plugin_path() . '/classes/views/shared/form-nav.php';
 }
 function import_xml()
 {
     // install test data in older format
     add_filter('frm_default_templates_files', 'FrmUnitTest::install_data');
     FrmXMLController::add_default_templates();
     $form = FrmForm::getOne('contact-db12');
     $this->assertEquals($form->form_key, 'contact-db12');
 }
 public static function _logic_row()
 {
     check_ajax_referer('frm_ajax', 'nonce');
     $meta_name = FrmAppHelper::get_param('meta_name', '', 'get', 'sanitize_title');
     $form_id = FrmAppHelper::get_param('form_id', '', 'get', 'absint');
     $key = FrmAppHelper::get_param('email_id', '', 'get', 'sanitize_title');
     $type = FrmAppHelper::get_param('type', '', 'get', 'sanitize_title');
     $form = FrmForm::getOne($form_id);
     FrmProFormsController::include_logic_row(array('form_id' => $form->id, 'form' => $form, 'meta_name' => $meta_name, 'condition' => array('hide_field_cond' => '==', 'hide_field' => ''), 'key' => $key, 'name' => 'frm_' . $type . '_action[' . $key . '][post_content][conditions][' . $meta_name . ']'));
     wp_die();
 }
Example #16
0
 function duplicate($id, $copy_keys = false, $blog_id = false)
 {
     global $wpdb;
     $values = $this->getOne($id, $blog_id, true);
     if (!$values or !is_numeric($values->frm_form_id)) {
         return false;
     }
     $new_values = array();
     foreach (array('post_name', 'post_title', 'post_excerpt', 'post_content', 'post_status', 'post_type') as $k) {
         $new_values[$k] = $values->{$k};
         unset($k);
     }
     $meta = array();
     foreach (array('form_id', 'entry_id', 'post_id', 'dyncontent', 'param', 'type', 'show_count', 'insert_loc') as $k) {
         $meta[$k] = $values->{'frm_' . $k};
         unset($k);
     }
     $default = FrmProDisplaysHelper::get_default_opts();
     $meta['options'] = array();
     foreach ($default as $k => $v) {
         if (isset($meta[$k])) {
             continue;
         }
         $meta['options'][$k] = $values->{'frm_' . $k};
         unset($k);
         unset($v);
     }
     $meta['options']['copy'] = false;
     if ($blog_id) {
         $frm_form = new FrmForm();
         $old_form = $frm_form->getOne($values->frm_form_id, $blog_id);
         $new_form = $frm_form->getOne($old_form->form_key);
         $meta['form_id'] = $new_form->id;
     } else {
         $meta['form_id'] = $values->form_id;
     }
     $post_ID = wp_insert_post($new_values);
     $new_values = array_merge((array) $new_values, $meta);
     $this->update($post_ID, $new_values);
     return $post_ID;
 }
Example #17
0
 public static function save_wppost_actions($settings, $action)
 {
     $form_id = $action['menu_order'];
     if (isset($settings['post_custom_fields'])) {
         foreach ($settings['post_custom_fields'] as $cf_key => $n) {
             if (!isset($n['custom_meta_name'])) {
                 continue;
             }
             if ($n['meta_name'] == '' && $n['custom_meta_name'] != '') {
                 $settings['post_custom_fields'][$cf_key]['meta_name'] = $n['custom_meta_name'];
             }
             unset($settings['post_custom_fields'][$cf_key]['custom_meta_name']);
             unset($cf_key, $n);
         }
     }
     self::create_post_category_field($settings, $form_id);
     self::create_post_status_field($settings, $form_id);
     //update/create View
     if (!empty($settings['display_id'])) {
         if (is_numeric($settings['display_id'])) {
             //updating View
             $type = get_post_meta($settings['display_id'], 'frm_show_count', true);
             if ('one' == $type) {
                 $display = get_post($settings['display_id'], ARRAY_A);
                 $display['post_content'] = $_POST['dyncontent'];
                 wp_insert_post($display);
             } else {
                 update_post_meta($settings['display_id'], 'frm_dyncontent', $_POST['dyncontent']);
             }
         } else {
             if ('new' == $settings['display_id']) {
                 // Get form name for View title
                 $form = FrmForm::getOne($form_id);
                 if (!empty($form->name)) {
                     $post_title = $form->name;
                 } else {
                     $post_title = __('Single Post', 'formidable');
                 }
                 //create new
                 $cd_values = array('post_status' => 'publish', 'post_type' => 'frm_display', 'post_title' => $post_title, 'post_excerpt' => __('Used for the single post page', 'formidable'), 'post_content' => $_POST['dyncontent']);
                 $display_id = wp_insert_post($cd_values);
                 $settings['display_id'] = $display_id;
                 unset($cd_values);
                 update_post_meta($display_id, 'frm_param', 'entry');
                 update_post_meta($display_id, 'frm_type', 'display_key');
                 update_post_meta($display_id, 'frm_show_count', 'one');
                 update_post_meta($display_id, 'frm_form_id', $form_id);
             }
         }
     }
     return $settings;
 }
 public static function show()
 {
     global $frmdb, $frm_field, $frm_entry_meta, $frm_entry, $wpdb;
     if (!isset($_GET['form'])) {
         require FrmAppHelper::plugin_path() . '/pro/classes/views/frmpro-statistics/show.php';
         return;
     }
     $frm_form = new FrmForm();
     $form = $frm_form->getOne($_GET['form']);
     $form_options = maybe_unserialize($form->options);
     $fields = $frm_field->getAll("fi.type not in ('divider','captcha','break','rte','textarea','file','grid','html','signature','table') and fi.form_id=" . (int) $form->id, 'field_order ASC');
     $js = '';
     $data = array();
     $colors = '#21759B,#EF8C08,#C6C6C6';
     $data['time'] = self::get_daily_entries($form, array('is3d' => true, 'colors' => $colors));
     $data['month'] = self::get_daily_entries($form, array('is3d' => true, 'colors' => $colors), 'MONTH');
     foreach ($fields as $field) {
         $data[$field->id] = self::graph_shortcode(array('id' => $field->id, 'field' => $field, 'is3d' => true, 'min' => 0, 'colors' => $colors, 'width' => 650));
         unset($field);
     }
     include FrmAppHelper::plugin_path() . '/pro/classes/views/frmpro-statistics/show.php';
 }
Example #19
0
 function widget($args, $instance)
 {
     extract($args);
     $frm_form = new FrmForm();
     $form_name = $frm_form->getName($instance['form']);
     $title = apply_filters('widget_title', empty($instance['title']) ? $form_name : $instance['title']);
     $instance['description'] = isset($instance['description']) ? $instance['description'] : false;
     echo $before_widget;
     $select_class = (isset($instance['select_width']) and $instance['select_width']) ? ' frm_set_select' : '';
     echo '<div class="frm_form_widget' . $select_class . '">';
     if ($title) {
         echo $before_title . stripslashes($title) . $after_title;
     }
     if (isset($instance['size']) and is_numeric($instance['size'])) {
         global $frm_vars;
         $frm_vars['sidebar_width'] = $instance['size'];
     }
     echo FrmFormsController::show_form($instance['form'], '', false, $instance['description']);
     $frm_vars['sidebar_width'] = '';
     echo '</div>';
     echo $after_widget;
 }
 function _setup_post_values($form_id)
 {
     $fields = FrmField::get_all_for_form($form_id);
     $form = FrmForm::getOne($form_id);
     $_POST = array('page' => 'formidable', 'frm_action' => 'update', 'id' => $form_id, 'action' => 'update', 'frm_save_form' => wp_create_nonce('frm_save_form_nonce'), 'status' => 'published', 'new_status' => '', 'name' => $form->name, 'frm_fields_submitted' => array(), 'item_meta' => array(), 'field_options' => array());
     foreach ($fields as $field) {
         $_POST['frm_fields_submitted'][] = $field->id;
         $_POST['item_meta'][$field->id] = 'default';
         $field_options = array('description_' . $field->id => '', 'type_' . $field->id => '', 'required_indicator_' . $field->id => '*', 'field_key_' . $field->id => $field->field_key, 'classes_' . $field->id => '', 'label_' . $field->id => '', 'size_' . $field->id => '', 'max_' . $field->id => '', 'admin_only_' . $field->id => '', 'use_calc_' . $field->id => 1, 'calc_' . $field->id => '', 'calc_dec_' . $field->id => '', 'show_hide_' . $field->id => 'show', 'any_all_' . $field->id => 'any', 'blank_' . $field->id => 'This field cannot be blank.', 'unique_msg_' . $field->id => '');
         $_POST['field_options'] = array_merge($_POST['field_options'], $field_options);
         $_REQUEST = $_POST;
     }
 }
 public function no_items()
 {
     $s = isset($_REQUEST['s']) ? $_REQUEST['s'] : '';
     if (!empty($s)) {
         _e('No Entries Found', 'formidable');
         return;
     }
     $form_id = $form = $this->params['form'];
     if ($form_id) {
         $form = FrmForm::getOne($form_id);
     }
     $colspan = $this->get_column_count();
     include FrmAppHelper::plugin_path() . '/classes/views/frm-entries/no_entries.php';
 }
 public static function get_form_nav($form, $show_nav = false, $title = 'show')
 {
     $show_nav = FrmAppHelper::get_param('show_nav', $show_nav, 'get', 'absint');
     if (empty($show_nav) || !$form) {
         return;
     }
     FrmForm::maybe_get_form($form);
     if (!is_object($form)) {
         return;
     }
     $id = $form->id;
     $current_page = self::get_current_page();
     $nav_items = self::get_form_nav_items($form);
     include FrmAppHelper::plugin_path() . '/classes/views/shared/form-nav.php';
 }
 /**
  * @covers FrmForm::destroy
  */
 function test_destroy()
 {
     $forms = FrmForm::getAll();
     $this->assertNotEmpty(count($forms));
     foreach ($forms as $form) {
         if ($form->is_template) {
             continue;
         }
         $id = FrmForm::destroy($form->id);
         $form_exists = FrmForm::getOne($form->id);
         $this->assertEmpty($form_exists, 'Failed to delete form ' . $form->form_key);
         $subforms_exist = FrmForm::getAll(array('parent_form_id' => $form->id));
         $this->assertEmpty($subforms_exist, 'Failed to delete child forms for parent form ' . $form->form_key);
     }
 }
 /**
  * @covers FrmField::get_all_for_form
  */
 function test_get_all_for_form()
 {
     $forms = array('basic_test' => array('form_key' => $this->contact_form_key, 'count' => 8), 'repeat' => array('form_key' => $this->all_fields_form_key, 'count' => 33 + 3), 'no_repeat_or_embed' => array('form_key' => $this->all_fields_form_key, 'count' => 33), 'repeat_and_embed' => array('form_key' => $this->all_fields_form_key, 'count' => 33 + 3 + 8));
     foreach ($forms as $test => $args) {
         $form_id = FrmForm::getIdByKey($args['form_key']);
         if ($test == 'no_repeat_or_embed') {
             $fields = FrmField::get_all_for_form($form_id, '', 'exclude', 'exclude');
         } else {
             if ($test == 'repeat_and_embed') {
                 $fields = FrmField::get_all_for_form($form_id, '', 'include', 'include');
             } else {
                 $fields = FrmField::get_all_for_form($form_id);
             }
         }
         $this->assertNotEmpty($fields);
         $this->assertEquals($args['count'], count($fields), 'An incorrect number of fields are retrieved with FrmField::get_all_for_form.');
     }
 }
Example #25
0
 public function widget($args, $instance)
 {
     if (empty($instance['title'])) {
         $title = FrmForm::getName($instance['form']);
     } else {
         $title = $instance['title'];
     }
     $title = apply_filters('widget_title', $title);
     $instance['description'] = isset($instance['description']) ? $instance['description'] : false;
     echo $args['before_widget'];
     echo '<div class="frm_form_widget">';
     if ($title) {
         echo $args['before_title'] . stripslashes($title) . $args['after_title'];
     }
     echo FrmFormsController::show_form($instance['form'], '', false, $instance['description']);
     echo '</div>';
     echo $args['after_widget'];
 }
 public static function get_form_nav($form, $show_nav = '', $title = 'show')
 {
     global $pagenow, $frm_vars;
     $show_nav = FrmAppHelper::get_param('show_nav', $show_nav, 'get', 'absint');
     if (empty($show_nav)) {
         return;
     }
     $current_page = isset($_GET['page']) ? FrmAppHelper::simple_get('page', 'sanitize_title') : FrmAppHelper::simple_get('post_type', 'sanitize_title', 'None');
     if ($form) {
         FrmForm::maybe_get_form($form);
         if (is_object($form)) {
             $id = $form->id;
         }
     }
     if (!isset($id)) {
         $form = $id = false;
     }
     include FrmAppHelper::plugin_path() . '/classes/views/shared/form-nav.php';
 }
 /**
  * @covers FrmDb::migrate_to_17
  */
 function test_migrate_from_12_to_17()
 {
     $this->frm_install();
     update_option('frm_db_version', 12);
     $form = FrmForm::getOne('contact-db12');
     $this->assertNotEmpty($form);
     $this->assertTrue(is_numeric($form->id));
     $notification = array(0 => array('email_to' => '*****@*****.**', 'also_email_to' => array(1, 2), 'reply_to' => '*****@*****.**', 'reply_to_name' => 'Reply to me', 'cust_reply_to' => '', 'cust_reply_to_name' => '', 'plain_text' => 1, 'email_message' => 'This is my email message. [default-message]', 'email_subject' => 'The subject', 'update_email' => 2, 'inc_user_info' => 1));
     $form->options['notification'] = $notification;
     global $wpdb;
     $updated = $wpdb->update($wpdb->prefix . 'frm_forms', array('options' => maybe_serialize($form->options)), array('id' => $form->id));
     FrmForm::clear_form_cache();
     $this->assertEquals($updated, 1);
     $form = FrmForm::getOne('contact-db12');
     $this->assertNotEmpty($form->options, 'The form settings are empty');
     $this->assertTrue(isset($form->options['notification']), 'The old notification settings are missing');
     $this->assertEquals($form->options['notification'][0]['email_to'], '*****@*****.**');
     // migrate data
     FrmAppController::install();
     $form_actions = FrmFormAction::get_action_for_form($form->id, 'email');
     foreach ($form_actions as $action) {
         $this->assertTrue(strpos($action->post_content['email_to'], '*****@*****.**') !== false);
     }
 }
</option>
					<?php 
}
?>
					</select></td>								
				</tr>
					<tr>
					<td><input type='checkbox' name='use_formidable_forms'/></td>
					<td><?php 
_e('Use Formidable Forms', 'dvinwcql');
?>
 - <select name='formidable_form_select' id='formidable_form_select'>
						<option value=''>Select Form</option>
						<?php 
if (class_exists('FrmForm')) {
    $frm_form = new FrmForm();
    $forms = $frm_form->getAll("is_template=0 AND status = 'published'", ' ORDER BY name');
} else {
    $forms = array();
}
foreach ($forms as $form) {
    ?>
								<option value='<?php 
    echo $form->id;
    ?>
'><?php 
    echo $form->name;
    ?>
</option>
					<?php 
}
Example #29
0
 /**
  * Update parent_form_id for child forms that were imported before parents
  *
  * @since 2.0.13
  *
  * @param array $child_forms_missing_parent
  * @param array $imported_forms
  */
 private static function update_child_form_parents($child_forms_missing_parent, $imported_forms)
 {
     foreach ($child_forms_missing_parent as $old_parent_form_id => $child_form_ids) {
         if (isset($imported_forms[$old_parent_form_id])) {
             // Update all children with this old parent_form_id
             $new_parent_form_id = (int) $imported_forms[$old_parent_form_id];
             foreach ($child_form_ids as $child_form_id) {
                 FrmForm::update($child_form_id, array('parent_form_id' => $new_parent_form_id));
             }
         }
     }
 }
 public static function get_current_form_id()
 {
     _deprecated_function(__FUNCTION__, '2.0.9', 'FrmForm::get_current_form_id');
     return FrmForm::get_current_form_id();
 }