Formidable Forms – Form Builder for WordPress - Version 1.0.12

Version Description

  • Validated HTML markup for front-end form
  • Simplified the way a default template is created so it will also get updated with any changes
  • Really fixed the after HTML field this time
  • Changed option to email form to default to admin's email address instead of blank
Download this release

Release Info

Developer sswells
Plugin Icon 128x128 Formidable Forms – Form Builder for WordPress
Version 1.0.12
Comparing to
See all releases

Code changes from version 1.0 to 1.0.12

Files changed (110) hide show
  1. classes/controllers/FrmApiController.php +5 -17
  2. classes/controllers/FrmAppController.php +53 -142
  3. classes/controllers/FrmEntriesController.php +18 -13
  4. classes/controllers/FrmFieldsController.php +39 -11
  5. classes/controllers/FrmFormsController.php +23 -21
  6. classes/controllers/FrmSettingsController.php +19 -64
  7. classes/controllers/FrmStatisticsController.php +2 -3
  8. classes/helpers/FrmAppHelper.php +119 -42
  9. classes/helpers/FrmEntriesHelper.php +53 -10
  10. classes/helpers/FrmFieldsHelper.php +77 -5
  11. classes/helpers/FrmFormsHelper.php +56 -8
  12. classes/helpers/FrmSettingsHelper.php +0 -14
  13. classes/models/FrmEntry.php +79 -29
  14. classes/models/FrmEntryMeta.php +23 -35
  15. classes/models/FrmField.php +123 -138
  16. classes/models/FrmForm.php +43 -45
  17. classes/models/FrmNotification.php +5 -4
  18. classes/models/FrmSettings.php +21 -8
  19. classes/models/FrmUpdate.php +283 -0
  20. classes/models/FrmUtils.php +0 -64
  21. classes/templates/contact.php +63 -0
  22. classes/views/frm-entries/direct.php +4 -0
  23. classes/views/frm-entries/form.php +39 -27
  24. classes/views/frm-entries/frm-entry.php +9 -7
  25. classes/views/frm-entries/new.php +5 -5
  26. classes/views/frm-fields/input.php +31 -0
  27. classes/views/frm-fields/show.php +1 -40
  28. classes/views/frm-fields/single-option.php +1 -1
  29. classes/views/frm-forms/add_field.php +32 -23
  30. classes/views/frm-forms/add_field_links.php +8 -2
  31. classes/views/frm-forms/default-templates.php +4 -0
  32. classes/views/frm-forms/edit.php +1 -1
  33. classes/views/frm-forms/footer.php +132 -19
  34. classes/views/frm-forms/form.php +59 -5
  35. classes/views/frm-forms/list.php +11 -6
  36. classes/views/frm-forms/new.php +1 -1
  37. classes/views/frm-settings/form.php +8 -5
  38. classes/views/frm-settings/pro-settings.php +0 -51
  39. classes/views/shared/errors.php +8 -8
  40. classes/views/shared/head.php +9 -2
  41. classes/views/shared/item-table-nav.php +1 -17
  42. classes/views/shared/nav.php +1 -0
  43. css/frm_admin.css +15 -25
  44. formidable.php +24 -27
  45. images/ajax_loader.gif +0 -0
  46. images/help.png +0 -0
  47. images/reload.png +0 -0
  48. images/required_loader.gif +0 -0
  49. images/wpspin_light.gif +0 -0
  50. js/jquery/jquery-1.3.2.min.js +19 -0
  51. js/jquery/jquery-ui-1.7.1.custom.min.js +0 -273
  52. js/jquery/jquery-ui-1.7.2.min.js +10 -0
  53. js/jquery/jquery-ui-themepicker.js +193 -0
  54. js/json2.js +461 -0
  55. js/list-items.js +14 -17
  56. js/nicedit.js +118 -0
  57. js/ofc-library/JSON.php +806 -0
  58. js/ofc-library/README.txt +16 -0
  59. js/ofc-library/dot_base.php +231 -0
  60. js/ofc-library/json_format.php +86 -0
  61. js/ofc-library/ofc_area_base.php +40 -0
  62. js/ofc-library/ofc_area_hollow.php +10 -0
  63. js/ofc-library/ofc_area_line.php +10 -0
  64. js/ofc-library/ofc_arrow.php +27 -0
  65. js/ofc-library/ofc_bar.php +34 -0
  66. js/ofc-library/ofc_bar_3d.php +22 -0
  67. js/ofc-library/ofc_bar_base.php +97 -0
  68. js/ofc-library/ofc_bar_filled.php +39 -0
  69. js/ofc-library/ofc_bar_glass.php +131 -0
  70. js/ofc-library/ofc_bar_sketch.php +29 -0
  71. js/ofc-library/ofc_bar_stack.php +55 -0
  72. js/ofc-library/ofc_candle.php +41 -0
  73. js/ofc-library/ofc_hbar.php +64 -0
  74. js/ofc-library/ofc_line.php +157 -0
  75. js/ofc-library/ofc_line_base.php +92 -0
  76. js/ofc-library/ofc_line_dot.php +33 -0
  77. js/ofc-library/ofc_line_hollow.php +9 -0
  78. js/ofc-library/ofc_line_style.php +11 -0
  79. js/ofc-library/ofc_menu.php +56 -0
  80. js/ofc-library/ofc_pie.php +257 -0
  81. js/ofc-library/ofc_radar_axis.php +47 -0
  82. js/ofc-library/ofc_radar_axis_labels.php +15 -0
  83. js/ofc-library/ofc_radar_spoke_labels.php +15 -0
  84. js/ofc-library/ofc_scatter.php +47 -0
  85. js/ofc-library/ofc_scatter_line.php +49 -0
  86. js/ofc-library/ofc_shape.php +25 -0
  87. js/ofc-library/ofc_sugar.php +43 -0
  88. js/ofc-library/ofc_tags.php +133 -0
  89. js/ofc-library/ofc_title.php +39 -0
  90. js/ofc-library/ofc_tooltip.php +67 -0
  91. js/ofc-library/ofc_upload_image.php +70 -0
  92. js/ofc-library/ofc_x_axis.php +140 -0
  93. js/ofc-library/ofc_x_axis_label.php +45 -0
  94. js/ofc-library/ofc_x_axis_labels.php +69 -0
  95. js/ofc-library/ofc_x_legend.php +15 -0
  96. js/ofc-library/ofc_y_axis.php +17 -0
  97. js/ofc-library/ofc_y_axis_base.php +116 -0
  98. js/ofc-library/ofc_y_axis_label.php +38 -0
  99. js/ofc-library/ofc_y_axis_labels.php +57 -0
  100. js/ofc-library/ofc_y_axis_right.php +6 -0
  101. js/ofc-library/ofc_y_legend.php +15 -0
  102. js/ofc-library/open-flash-chart-object.php +109 -0
  103. js/ofc-library/open-flash-chart.php +178 -0
  104. js/open-flash-chart.swf +0 -0
  105. js/swfobject.js +5 -0
  106. readme.txt +79 -10
  107. screenshot-1.png +0 -0
  108. screenshot-2.png +0 -0
  109. screenshot-3.png +0 -0
  110. todo.txt +0 -60
classes/controllers/FrmApiController.php CHANGED
@@ -11,7 +11,7 @@ class FrmApiController{
11
 
12
  $form_key = sanitize_title($args[0]);
13
 
14
- $where = '';//" gr.form_key = '$form_key'";
15
  $items = $frm_entry->getAll($where);
16
 
17
  $list = $form_key;
@@ -26,7 +26,7 @@ class FrmApiController{
26
  global $frm_entry, $frm_form, $frm_entry_meta;
27
 
28
  $defaults = array(
29
- 'form_key' => '', 'parent_id' => '',
30
  'order' => '', 'limit' => '',
31
  'search' =>'', 'search_type' => '',
32
  'search_field' => '', 'search_operator' => 'LIKE'
@@ -34,11 +34,9 @@ class FrmApiController{
34
 
35
  $r = wp_parse_args( $args, $defaults );
36
 
37
- $form = $frm_form->getOneByKey($r['form_key']);
38
 
39
- $where = " (it.form_id='". $form->id ."' or gr.form_id='". $form->id ."')";
40
- if (!($r['parent_id'] == ''))
41
- $where .= " and it.parent_item_id='". $r['parent_id'] ."'";
42
 
43
  if (!($r['order'] == ''))
44
  $r['order'] = " ORDER BY {$r['order']}";
@@ -65,7 +63,7 @@ class FrmApiController{
65
 
66
  function get_frm_item($item_key){
67
  global $frm_entry;
68
- return $frm_entry->getOneByKey( $item_key );
69
  }
70
 
71
  function get_frm_item_by_id($id){
@@ -73,16 +71,6 @@ class FrmApiController{
73
  return $frm_entry->getOne( $id );
74
  }
75
 
76
- function get_frm_edit_link($id){
77
- global $current_user, $frm_siteurl;
78
-
79
- $output = '';
80
- if($current_user->wp_capabilities['administrator'] == 1) {
81
- $output = "<span class='frm_edit'>[<a href='{$frm_siteurl}/wp-admin/admin.php?page=". FRM_PLUGIN_NAME ."-entries&action=edit&id={$id}'>Edit</a>]</span>";
82
- }
83
- return $output;
84
- }
85
-
86
  }
87
 
88
  ?>
11
 
12
  $form_key = sanitize_title($args[0]);
13
 
14
+ $where = '';//" fr.form_key = '$form_key'";
15
  $items = $frm_entry->getAll($where);
16
 
17
  $list = $form_key;
26
  global $frm_entry, $frm_form, $frm_entry_meta;
27
 
28
  $defaults = array(
29
+ 'form_key' => '',
30
  'order' => '', 'limit' => '',
31
  'search' =>'', 'search_type' => '',
32
  'search_field' => '', 'search_operator' => 'LIKE'
34
 
35
  $r = wp_parse_args( $args, $defaults );
36
 
37
+ $form = $frm_form->getOne($r['form_key']);
38
 
39
+ $where = " (it.form_id='". $form->id ."')";
 
 
40
 
41
  if (!($r['order'] == ''))
42
  $r['order'] = " ORDER BY {$r['order']}";
63
 
64
  function get_frm_item($item_key){
65
  global $frm_entry;
66
+ return $frm_entry->getOne( $item_key );
67
  }
68
 
69
  function get_frm_item_by_id($id){
71
  return $frm_entry->getOne( $id );
72
  }
73
 
 
 
 
 
 
 
 
 
 
 
74
  }
75
 
76
  ?>
classes/controllers/FrmAppController.php CHANGED
@@ -3,6 +3,7 @@
3
  class FrmAppController{
4
  function FrmAppController(){
5
  add_action('admin_menu', array( $this, 'menu' ));
 
6
  add_filter('the_content', array( $this, 'page_route' ), 1);
7
  add_action('init', array($this, 'front_head'));
8
  add_action('admin_init', array( $this, 'admin_js'));
@@ -21,20 +22,27 @@ class FrmAppController{
21
 
22
  add_menu_page(FRM_PLUGIN_TITLE, FRM_PLUGIN_TITLE, 8, FRM_PLUGIN_NAME, array($frm_forms_controller,'route'), FRM_URL . '/images/icon_16.png');
23
 
24
- if(!$frmpro_is_installed){
25
- add_submenu_page(FRM_PLUGIN_TITLE, FRM_PLUGIN_TITLE .' | Pro Statistics', 'Pro Statistics', 8, FRM_PLUGIN_TITLE.'-statistics',array($this,''));
26
- }
 
 
 
 
 
 
27
  }
28
 
29
  function head(){
30
- $css_file = 'frm_admin.css';
 
31
  $js_file = 'list-items.js';
32
  require_once(FRM_VIEWS_PATH . '/shared/head.php');
33
  }
34
 
35
  function admin_js(){
36
  wp_enqueue_script('jQuery');
37
- wp_enqueue_script('jQuery-custom', FRM_URL.'/js/jquery/jquery-ui-1.7.1.custom.min.js');
38
  wp_enqueue_script('jQuery-in-place-edit-patched', FRM_URL.'/js/jquery/jquery.editinplace.packed.js');
39
 
40
  add_action( 'admin_print_footer_scripts', 'wp_tiny_mce', 25 );
@@ -44,11 +52,12 @@ class FrmAppController{
44
  }
45
 
46
  function front_head(){
47
- wp_enqueue_style('frm-forms', FRM_URL.'/css/frm_display.css');
 
48
  }
49
 
50
  function install(){
51
- global $wpdb, $frm_utils, $frm_form, $frm_field;
52
  $db_version = 1.0; // this is the version of the database we're moving to
53
  $old_db_version = get_option('frm_db_version');
54
 
@@ -57,14 +66,6 @@ class FrmAppController{
57
  $items_table = $wpdb->prefix . "frm_items";
58
  $item_metas_table = $wpdb->prefix . "frm_item_metas";
59
 
60
- $charset_collate = '';
61
- if( $wpdb->has_cap( 'collation' ) ){
62
- if( !empty($wpdb->charset) )
63
- $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
64
- if( !empty($wpdb->collate) )
65
- $charset_collate .= " COLLATE $wpdb->collate";
66
- }
67
-
68
  if ($db_version != $old_db_version){
69
  require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
70
 
@@ -138,153 +139,63 @@ class FrmAppController{
138
 
139
  dbDelta($sql);
140
 
141
- /**** ADD DEFAULT FORMS ****/
142
- if ($frm_form->getRecordCount("form_key='contact' and is_template='1'") <= 0){
143
- $values = FrmFormsHelper::setup_new_vars();
144
- $values['name'] = 'Contact Us';
145
- $values['form_key'] = 'contact';
146
- $values['description'] = 'We would like to hear from you. Please send us a message by filling out the form below and we will get back with you shortly.';
147
- $values['is_template'] = 1;
148
- $values['default_template'] = 1;
149
- $form_id = $frm_form->create( $values );
150
-
151
- $field_options = array();
152
- $field_options['label'] = 'top';
153
- $field_options['size'] = '75';
154
- $field_options['max'] = '';
155
- $field_options['required_indicator'] = '*';
156
-
157
-
158
- $field_options['blank'] = 'Name cannot be blank';
159
- $field_options['invalid'] = '';
160
- $frm_field->create( array(
161
- 'field_key' => 'name',
162
- 'name' => 'Name',
163
- 'description' => '',
164
- 'type' => 'text',
165
- 'default_value' => '',
166
- 'options' => '',
167
- 'form_id' => $form_id,
168
- 'field_order' => 1,
169
- 'required' => true,
170
- 'field_options' => $field_options ));
171
-
172
- $field_options['blank'] = 'Email cannot be blank';
173
- $field_options['invalid'] = 'Please enter a valid email address';
174
- $frm_field->create( array(
175
- 'field_key' => 'email',
176
- 'name' => 'Email',
177
- 'description' => '',
178
- 'type' => 'email',
179
- 'default_value' => '',
180
- 'options' => '',
181
- 'form_id' => $form_id,
182
- 'field_order' => 2,
183
- 'required' => true,
184
- 'field_options' => $field_options ));
185
-
186
- $field_options['blank'] = 'Website cannot be blank';
187
- $field_options['invalid'] = 'Website is an invalid format';
188
- $frm_field->create( array(
189
- 'field_key' => 'website',
190
- 'name' => 'Website',
191
- 'description' => '',
192
- 'type' => 'website',
193
- 'default_value' => '',
194
- 'options' => '',
195
- 'form_id' => $form_id,
196
- 'field_order' => 3,
197
- 'required' => false,
198
- 'field_options' => $field_options ));
199
-
200
- $field_options['blank'] = 'Subject cannot be blank';
201
- $field_options['invalid'] = '';
202
- $frm_field->create( array(
203
- 'field_key' => 'subject',
204
- 'name' => 'Subject',
205
- 'description' => '',
206
- 'type' => 'text',
207
- 'default_value' => '',
208
- 'options' => '',
209
- 'form_id' => $form_id,
210
- 'field_order' => 4,
211
- 'required' => true,
212
- 'field_options' => $field_options ));
213
-
214
- $field_options['size'] = '65';
215
- $field_options['max'] = '5';
216
- $field_options['blank'] = 'Message cannot be blank';
217
- $frm_field->create( array(
218
- 'field_key' => 'message',
219
- 'name' => 'Message',
220
- 'description' => '',
221
- 'type' => 'textarea',
222
- 'default_value' => '',
223
- 'options' => '',
224
- 'form_id' => $form_id,
225
- 'field_order' => 5,
226
- 'required' => true,
227
- 'field_options' => $field_options ));
228
-
229
- $field_options['label'] = 'none';
230
- $field_options['size'] = '';
231
- $field_options['max'] = '';
232
- $frm_field->create( array(
233
- 'field_key' => 'captcha',
234
- 'name' => 'Captcha',
235
- 'description' => '',
236
- 'type' => 'captcha',
237
- 'default_value' => '',
238
- 'options' => '',
239
- 'form_id' => $form_id,
240
- 'field_order' => 6,
241
- 'required' => false,
242
- 'field_options' => $field_options ));
243
- }
244
-
245
  /***** SAVE DB VERSION *****/
246
- update_option('frm_db_version',$db_version);
247
  }
 
 
 
 
 
 
 
 
 
 
 
 
248
  }
249
 
250
 
251
  // Routes for wordpress pages -- we're just replacing content here folks.
252
  function page_route($content){
253
- global $post, $frm_settings, $frm_forms_controller;
254
 
255
- if( $post->ID == $frm_settings->preview_page_id){
256
- $frm_forms_controller->page_preview();
257
- return '';
258
- }
 
259
 
260
- return $content;
261
  }
262
 
263
  // The tight way to process standalone requests dogg...
264
  function parse_standalone_request(){
265
- $plugin = $this->get_param('plugin');
266
- $action = $this->get_param('action');
267
- $controller = $this->get_param('controller');
268
 
269
- if( !empty($plugin) and $plugin == FRM_PLUGIN_NAME and !empty($controller) and !empty($action) ){
270
- $this->standalone_route($controller, $action);
271
- exit;
272
- }
273
  }
274
 
275
  // Routes for standalone / ajax requests
276
- function standalone_route($controller, $action){
277
- global $frm_forms_controller;
278
-
279
- if($controller=='forms'){
280
- if($action=='preview')
281
- $frm_forms_controller->preview($this->get_param('form'));
282
- }
 
283
  }
284
 
285
  // Utility function to grab the parameter whether it's a get or post
286
  function get_param($param, $default=''){
287
- return (isset($_POST[$param])?$_POST[$param]:(isset($_GET[$param])?$_GET[$param]:$default));
288
  }
289
 
290
 
@@ -297,7 +208,7 @@ class FrmAppController{
297
 
298
  function widget_text_filter( $content ){
299
  $regex = '/\[\s*formidable\s+.*\]/';
300
- return preg_replace_callback( $regex, 'widget_text_filter_callback', $content );
301
  }
302
 
303
 
3
  class FrmAppController{
4
  function FrmAppController(){
5
  add_action('admin_menu', array( $this, 'menu' ));
6
+ add_filter( 'plugin_action_links_'.FRM_PLUGIN_NAME.'/'.FRM_PLUGIN_NAME.'.php', array( $this, 'settings_link'), 10, 2 );
7
  add_filter('the_content', array( $this, 'page_route' ), 1);
8
  add_action('init', array($this, 'front_head'));
9
  add_action('admin_init', array( $this, 'admin_js'));
22
 
23
  add_menu_page(FRM_PLUGIN_TITLE, FRM_PLUGIN_TITLE, 8, FRM_PLUGIN_NAME, array($frm_forms_controller,'route'), FRM_URL . '/images/icon_16.png');
24
 
25
+ //if(!$frmpro_is_installed)
26
+ //add_submenu_page(FRM_PLUGIN_TITLE, FRM_PLUGIN_TITLE .' | Pro Statistics', 'Pro Statistics', 8, FRM_PLUGIN_TITLE.'-statistics',array($this,''));
27
+ }
28
+
29
+ // Adds a settings link to the plugins page
30
+ function settings_link($links, $file){
31
+ $settings = '<a href="'.admin_url('admin.php?page='.FRM_PLUGIN_NAME).'">' . __('Settings') . '</a>';
32
+ array_unshift($links, $settings);
33
+ return $links;
34
  }
35
 
36
  function head(){
37
+ global $frm_settings;
38
+ $css_file = array($frm_settings->theme_nicename => $frm_settings->theme_css, 'frm_admin' => FRM_URL. '/css/frm_admin.css');
39
  $js_file = 'list-items.js';
40
  require_once(FRM_VIEWS_PATH . '/shared/head.php');
41
  }
42
 
43
  function admin_js(){
44
  wp_enqueue_script('jQuery');
45
+ wp_enqueue_script('jQuery-ui-1.7.2', FRM_URL.'/js/jquery/jquery-ui-1.7.2.min.js');
46
  wp_enqueue_script('jQuery-in-place-edit-patched', FRM_URL.'/js/jquery/jquery.editinplace.packed.js');
47
 
48
  add_action( 'admin_print_footer_scripts', 'wp_tiny_mce', 25 );
52
  }
53
 
54
  function front_head(){
55
+ if (!is_admin())
56
+ wp_enqueue_style('frm-forms', FRM_URL.'/css/frm_display.css');
57
  }
58
 
59
  function install(){
60
+ global $wpdb, $frm_form, $frm_field, $frm_app_helper;
61
  $db_version = 1.0; // this is the version of the database we're moving to
62
  $old_db_version = get_option('frm_db_version');
63
 
66
  $items_table = $wpdb->prefix . "frm_items";
67
  $item_metas_table = $wpdb->prefix . "frm_item_metas";
68
 
 
 
 
 
 
 
 
 
69
  if ($db_version != $old_db_version){
70
  require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
71
 
139
 
140
  dbDelta($sql);
141
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
142
  /***** SAVE DB VERSION *****/
143
+ update_option('frm_db_version',$db_version);
144
  }
145
+
146
+ /**** ADD DEFAULT TEMPLATES ****/
147
+ $templates = glob(FRM_TEMPLATES_PATH."/*.php");
148
+
149
+ for($i = count($templates) - 1; $i >= 0; $i--){
150
+ $filename = preg_replace("#".FRM_TEMPLATES_PATH."/#","",$templates[$i]);
151
+ $filename = str_replace('.php','', $filename);
152
+ $form = $frm_form->getAll("form_key='{$filename}' and is_template='1' and default_template='1'", '', ' LIMIT 1');
153
+ require_once($templates[$i]);
154
+ }
155
+
156
+ do_action('frm_after_install');
157
  }
158
 
159
 
160
  // Routes for wordpress pages -- we're just replacing content here folks.
161
  function page_route($content){
162
+ global $post, $frm_settings;
163
 
164
+ if( $post && $post->ID == $frm_settings->preview_page_id && isset($_GET['form'])){
165
+ global $frm_forms_controller;
166
+ $frm_forms_controller->page_preview();
167
+ return;
168
+ }
169
 
170
+ return $content;
171
  }
172
 
173
  // The tight way to process standalone requests dogg...
174
  function parse_standalone_request(){
175
+ $plugin = $this->get_param('plugin');
176
+ $action = $this->get_param('action');
177
+ $controller = $this->get_param('controller');
178
 
179
+ if( !empty($plugin) and $plugin == FRM_PLUGIN_NAME and !empty($controller) ){
180
+ $this->standalone_route($controller, $action);
181
+ exit;
182
+ }
183
  }
184
 
185
  // Routes for standalone / ajax requests
186
+ function standalone_route($controller, $action=''){
187
+ global $frm_forms_controller;
188
+
189
+ if($controller=='forms'){
190
+ //if($action=='preview')
191
+ $frm_forms_controller->preview($this->get_param('form'));
192
+ }else
193
+ do_action('frm_standalone_route', $controller, $action);
194
  }
195
 
196
  // Utility function to grab the parameter whether it's a get or post
197
  function get_param($param, $default=''){
198
+ return (isset($_POST[$param])?$_POST[$param]:(isset($_GET[$param])?$_GET[$param]:$default));
199
  }
200
 
201
 
208
 
209
  function widget_text_filter( $content ){
210
  $regex = '/\[\s*formidable\s+.*\]/';
211
+ return preg_replace_callback( $regex, array($this, 'widget_text_filter_callback'), $content );
212
  }
213
 
214
 
classes/controllers/FrmEntriesController.php CHANGED
@@ -1,9 +1,10 @@
1
  <?php
2
 
3
  class FrmEntriesController{
 
 
4
  function FrmEntriesController(){
5
- add_action('admin_menu', array( $this, 'menu' ));
6
- $this->views = FRM_VIEWS_PATH.'/frm-entries/';
7
  }
8
 
9
  function menu(){
@@ -13,19 +14,19 @@ class FrmEntriesController{
13
  }
14
 
15
  function list_entries(){
16
- require_once($this->views .'list.php');
17
  }
18
 
19
- function show_form($id, $key, $title, $description){
20
  global $frm_form, $user_ID;
21
  if ($id) $form = $frm_form->getOne($id);
22
- else if ($key) $form = $frm_form->getOneByKey($key);
23
  if (!$form or $form->is_template or $form->status == 'draft')
24
  return 'Please select a valid form';
25
  else if ($form->logged_in and !$user_ID)
26
  return 'You must log in';
27
  else
28
- return $this->get_form($this->views.'frm-entry.php', $form, $title, $description);
29
  }
30
 
31
  function new_entry($form){
@@ -33,6 +34,8 @@ class FrmEntriesController{
33
  $fields = $frm_field->getAll("fi.form_id='$form->id'", ' ORDER BY field_order');
34
  $values = FrmEntriesHelper::setup_new_vars($fields);
35
  $form_name = $form->name;
 
 
36
 
37
  $params = $this->get_params($form);
38
  $message = '';
@@ -41,7 +44,7 @@ class FrmEntriesController{
41
  do_action('frm_display_form_action', $params, $fields, $form, $title, $description);
42
  if (apply_filters('frm_continue_to_new', true)){
43
  $values = FrmEntriesHelper::setup_new_vars($fields);
44
- require_once($this->views .'new.php');
45
  }
46
  }
47
 
@@ -50,9 +53,11 @@ class FrmEntriesController{
50
  $fields = $frm_field->getAll("fi.form_id='$form->id'", ' ORDER BY field_order');
51
  $values = FrmEntriesHelper::setup_new_vars($fields);
52
  $form_name = $form->name;
53
-
 
 
54
  $failed_message = "We're sorry. There was an error processing your responses.";
55
- $saved_message = "Your responses were successfully submitted. Thank you!";
56
 
57
  $params = $this->get_params($form);
58
  $message = '';
@@ -61,13 +66,13 @@ class FrmEntriesController{
61
 
62
  if( count($errors) > 0 ){
63
  $values = FrmEntriesHelper::setup_new_vars($fields);
64
- require_once($this->views.'new.php');
65
  }else{
66
  do_action('frm_validate_form_creation', $params, $fields, $form, $title, $description);
67
  if (apply_filters('frm_continue_to_create', true)){
68
- if ($frm_entry->create( $_POST ))
69
  echo $saved_message;
70
- else
71
  echo $failed_message;
72
  }
73
  }
@@ -91,7 +96,7 @@ class FrmEntriesController{
91
  $form = $frm_form->getAll('',' ORDER BY name',' LIMIT 1');
92
  $action = apply_filters('frm_show_new_entry_page','new',$form);
93
  $values = array();
94
- foreach (array('id' => '','form_name' => '', 'paged' => 1,'form' => $form->id,'field_id' => '', 'search' => '','sort' => '','sdir' => '', 'form' => $form->id, 'action' => $action) as $var => $default)
95
  $values[$var] = $frm_app_controller->get_param($var, $default);
96
 
97
  return $values;
1
  <?php
2
 
3
  class FrmEntriesController{
4
+ var $views;
5
+
6
  function FrmEntriesController(){
7
+ //add_action('admin_menu', array( $this, 'menu' ));
 
8
  }
9
 
10
  function menu(){
14
  }
15
 
16
  function list_entries(){
17
+ require_once(FRM_VIEWS_PATH.'/frm-entries/list.php');
18
  }
19
 
20
+ function show_form($id='', $key='', $title=false, $description=false){
21
  global $frm_form, $user_ID;
22
  if ($id) $form = $frm_form->getOne($id);
23
+ else if ($key) $form = $frm_form->getOne($key);
24
  if (!$form or $form->is_template or $form->status == 'draft')
25
  return 'Please select a valid form';
26
  else if ($form->logged_in and !$user_ID)
27
  return 'You must log in';
28
  else
29
+ return FrmEntriesController::get_form(FRM_VIEWS_PATH.'/frm-entries/frm-entry.php', $form, $title, $description);
30
  }
31
 
32
  function new_entry($form){
34
  $fields = $frm_field->getAll("fi.form_id='$form->id'", ' ORDER BY field_order');
35
  $values = FrmEntriesHelper::setup_new_vars($fields);
36
  $form_name = $form->name;
37
+ $form_options = stripslashes_deep(unserialize($form->options));
38
+ $submit = isset($form_options['submit_value'])?$form_options['submit_value']:'Submit';
39
 
40
  $params = $this->get_params($form);
41
  $message = '';
44
  do_action('frm_display_form_action', $params, $fields, $form, $title, $description);
45
  if (apply_filters('frm_continue_to_new', true)){
46
  $values = FrmEntriesHelper::setup_new_vars($fields);
47
+ require_once(FRM_VIEWS_PATH.'/frm-entries/new.php');
48
  }
49
  }
50
 
53
  $fields = $frm_field->getAll("fi.form_id='$form->id'", ' ORDER BY field_order');
54
  $values = FrmEntriesHelper::setup_new_vars($fields);
55
  $form_name = $form->name;
56
+ $form_options = stripslashes_deep(unserialize($form->options));
57
+
58
+ $submit = isset($form_options['submit_value'])?$form_options['submit_value']:'Submit';
59
  $failed_message = "We're sorry. There was an error processing your responses.";
60
+ $saved_message = (isset($form_options['success_msg']) && $form_options['success_msg'] != '') ? $form_options['success_msg'] :"Your responses were successfully submitted. Thank you!";
61
 
62
  $params = $this->get_params($form);
63
  $message = '';
66
 
67
  if( count($errors) > 0 ){
68
  $values = FrmEntriesHelper::setup_new_vars($fields);
69
+ require_once(FRM_VIEWS_PATH.'/frm-entries/new.php');
70
  }else{
71
  do_action('frm_validate_form_creation', $params, $fields, $form, $title, $description);
72
  if (apply_filters('frm_continue_to_create', true)){
73
+ if ($frm_entry->create( $_POST )){
74
  echo $saved_message;
75
+ }else
76
  echo $failed_message;
77
  }
78
  }
96
  $form = $frm_form->getAll('',' ORDER BY name',' LIMIT 1');
97
  $action = apply_filters('frm_show_new_entry_page','new',$form);
98
  $values = array();
99
+ foreach (array('id' => '', 'form_name' => '', 'paged' => 1, 'form' => $form->id, 'form_id' => $form->id, 'field_id' => '', 'search' => '', 'sort' => '', 'sdir' => '', 'action' => $action) as $var => $default)
100
  $values[$var] = $frm_app_controller->get_param($var, $default);
101
 
102
  return $values;
classes/controllers/FrmFieldsController.php CHANGED
@@ -2,17 +2,19 @@
2
 
3
  class FrmFieldsController{
4
  function FrmFieldsController(){
5
- add_filter('frm_field_type',array( $this, 'change_type'));
6
  add_action('wp_ajax_frm_insert_field', array($this, 'create') );
7
  add_action('wp_ajax_frm_field_name_in_place_edit', array($this, 'edit_name') );
8
  add_action('wp_ajax_frm_field_desc_in_place_edit', array($this, 'edit_description') );
9
  add_action('wp_ajax_frm_mark_required', array($this, 'mark_required') );
10
- add_action('wp_ajax_frm_unmark_required', array($this, 'unmark_required') );
 
11
  add_action('wp_ajax_frm_delete_field', array($this, 'destroy') );
12
  add_action('wp_ajax_frm_add_field_option',array($this, 'add_option'));
13
  add_action('wp_ajax_frm_field_option_ipe', array($this, 'edit_option') );
14
  add_action('wp_ajax_frm_delete_field_option',array($this, 'delete_option'));
15
  add_action('wp_ajax_frm_update_field_order', array($this, 'update_order') );
 
 
16
  }
17
 
18
  function create(){
@@ -58,15 +60,25 @@ class FrmFieldsController{
58
 
59
  function mark_required(){
60
  global $frm_field;
61
- $id = str_replace('req_field_', '', $_POST['field']);
62
- $frm_field->update($id, array('required' => '1'));
63
  die();
64
  }
65
-
66
- function unmark_required(){
 
 
 
 
 
 
 
 
 
67
  global $frm_field;
68
- $id = str_replace('req_field_', '', $_POST['field']);
69
- $frm_field->update($id, array('required' => '0'));
 
 
70
  die();
71
  }
72
 
@@ -136,14 +148,30 @@ class FrmFieldsController{
136
  function change_type($type){
137
  global $frm_field_selection, $frmpro_is_installed;
138
 
139
- if($frmpro_is_installed)
140
- return $type;
141
 
142
  $types = array_keys($frm_field_selection);
143
- if (!in_array($type, $types))
144
  $type = 'text';
145
 
146
  return $type;
147
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
148
  }
149
  ?>
2
 
3
  class FrmFieldsController{
4
  function FrmFieldsController(){
 
5
  add_action('wp_ajax_frm_insert_field', array($this, 'create') );
6
  add_action('wp_ajax_frm_field_name_in_place_edit', array($this, 'edit_name') );
7
  add_action('wp_ajax_frm_field_desc_in_place_edit', array($this, 'edit_description') );
8
  add_action('wp_ajax_frm_mark_required', array($this, 'mark_required') );
9
+ add_action('wp_ajax_frm_clear_on_focus', array($this, 'clear_on_focus') );
10
+ add_action('wp_ajax_frm_default_blank', array($this, 'default_blank') );
11
  add_action('wp_ajax_frm_delete_field', array($this, 'destroy') );
12
  add_action('wp_ajax_frm_add_field_option',array($this, 'add_option'));
13
  add_action('wp_ajax_frm_field_option_ipe', array($this, 'edit_option') );
14
  add_action('wp_ajax_frm_delete_field_option',array($this, 'delete_option'));
15
  add_action('wp_ajax_frm_update_field_order', array($this, 'update_order') );
16
+ add_filter('frm_field_type',array( $this, 'change_type'));
17
+ add_filter('frm_display_field_options', array($this, 'display_field_options'));
18
  }
19
 
20
  function create(){
60
 
61
  function mark_required(){
62
  global $frm_field;
63
+ $frm_field->update($_POST['field'], array('required' => $_POST['required']));
 
64
  die();
65
  }
66
+
67
+ function clear_on_focus(){
68
+ global $frm_field;
69
+ $field = $frm_field->getOne($_POST['field']);
70
+ $field_options = unserialize($field->field_options);
71
+ $field_options['clear_on_focus'] = $_POST['active'];
72
+ $frm_field->update($_POST['field'], array('field_options' => $field_options));
73
+ die();
74
+ }
75
+
76
+ function default_blank(){
77
  global $frm_field;
78
+ $field = $frm_field->getOne($_POST['field']);
79
+ $field_options = unserialize($field->field_options);
80
+ $field_options['default_blank'] = $_POST['active'];
81
+ $frm_field->update($_POST['field'], array('field_options' => $field_options));
82
  die();
83
  }
84
 
148
  function change_type($type){
149
  global $frm_field_selection, $frmpro_is_installed;
150
 
151
+ if ($frmpro_is_installed) return $type;
 
152
 
153
  $types = array_keys($frm_field_selection);
154
+ if (!in_array($type, $types) && $type != 'captcha')
155
  $type = 'text';
156
 
157
  return $type;
158
  }
159
+
160
+ function display_field_options($display){
161
+ if ($display['type'] == 'captcha'){
162
+ $display['required'] = false;
163
+ $display['default_blank'] = false;
164
+ }else if ($display['type'] == 'radio'){
165
+ $display['default_blank'] = false;
166
+ }else if ($display['type'] == 'text'){
167
+ $display['size'] = true;
168
+ $display['clear_on_focus'] = true;
169
+ }else if ($display['type'] == 'textarea'){
170
+ $display['size'] = true;
171
+ $display['clear_on_focus'] = true;
172
+ }
173
+
174
+ return $display;
175
+ }
176
  }
177
  ?>
classes/controllers/FrmFormsController.php CHANGED
@@ -9,7 +9,6 @@ class FrmFormsController{
9
  add_action('wp_ajax_frm_form_name_in_place_edit', array($this, 'edit_name') );
10
  add_action('wp_ajax_frm_form_desc_in_place_edit', array($this, 'edit_description') );
11
  add_action('wp_ajax_frm_delete_form_wo_fields',array($this, 'destroy_wo_fields'));
12
- $this->views = FRM_VIEWS_PATH.'/frm-forms/';
13
  }
14
 
15
  function menu(){
@@ -19,7 +18,7 @@ class FrmFormsController{
19
  }
20
 
21
  function head(){
22
- $css_file = 'frm_admin.css';
23
  $js_file = 'list-items.js';
24
  require_once(FRM_VIEWS_PATH . '/shared/head.php');
25
  }
@@ -44,15 +43,15 @@ class FrmFormsController{
44
  else if ($action == 'new'){
45
  $values = FrmFormsHelper::setup_new_vars();
46
  $id = $frm_form->create( $values );
47
- require_once($this->views . 'new.php');
48
  }else{
49
  $all_templates = $frm_form->getAll('is_template=1',' ORDER BY name');
50
- require_once($this->views . 'new-selection.php');
51
  }
52
  }
53
 
54
  function create(){
55
- global $frm_app_controller, $frm_app_helper, $frm_field_selection, $frm_entry, $frm_form, $frm_field, $frm_recaptcha_enabled, $frm_pro_field_selection, $frm_utils, $frmpro_is_installed;
56
  $errors = $frm_form->validate($_POST);
57
  $id = $frm_app_controller->get_param('id');
58
 
@@ -60,7 +59,7 @@ class FrmFormsController{
60
  $record = $frm_form->getOne( $id );
61
  $fields = $frm_field->getAll("fi.form_id=$id", ' ORDER BY field_order');
62
  $values = $frm_app_helper->setup_edit_vars($record,'forms',$fields,true);
63
- require_once($this->views . 'new.php');
64
  }else{
65
  $items = $frm_entry->getAll('',' ORDER BY it.name');
66
  $record = $frm_form->update( $id, $_POST, true );
@@ -138,11 +137,13 @@ class FrmFormsController{
138
 
139
  header("Content-Type: text/html; charset=utf-8");
140
 
 
 
141
  $key = (isset($_GET['form'])?$_GET['form']:(isset($_POST['form'])?$_POST['form']:''));
142
  $form = $frm_form->getAll("form_key='$key'",'',' LIMIT 1');
143
  if (!$form) $form = $frm_form->getAll('','',' LIMIT 1');
144
- $description = true;
145
- $title = true;
146
 
147
  require_once(FRM_VIEWS_PATH.'/frm-entries/direct.php');
148
  }
@@ -150,21 +151,22 @@ class FrmFormsController{
150
  function destroy(){
151
  global $frm_form;
152
  $params = $this->get_params();
 
153
  if ($frm_form->destroy( $params['id'] ))
154
  $message = "Form was Successfully Deleted";
155
  $this->display_forms_list($params, $message, '', 1);
156
  }
157
 
158
  function destroy_wo_fields(){
159
- global $frm_field, $frm_form;
160
  $id = $_POST['form_id'];
161
- if ($frm_field->getRecordCount('fi.form_id='.$id) <= 0)
162
  $frm_form->destroy($id);
163
  die();
164
  }
165
 
166
  function display_forms_list($params=false, $message='', $page_params_ov = false, $current_page_ov = false, $errors = array()){
167
- global $wpdb, $frm_utils, $frm_form, $frm_entry, $frm_page_size, $frmpro_is_installed;
168
 
169
  if(!$params)
170
  $params = $this->get_params();
@@ -197,12 +199,12 @@ class FrmFormsController{
197
  $sdir_str = $form_vars['sdir_str'];
198
  $search_str = $form_vars['search_str'];
199
 
200
- $record_count = $frm_form->getRecordCount($form_vars['where_clause']);
201
- $page_count = $frm_form->getPageCount($frm_page_size,$form_vars['where_clause']);
202
- $forms = $frm_form->getPage($current_page,$frm_page_size,$form_vars['where_clause'],$form_vars['order_by']);
203
- $page_last_record = $frm_utils->getLastRecordNum($record_count,$current_page,$frm_page_size);
204
- $page_first_record = $frm_utils->getFirstRecordNum($record_count,$current_page,$frm_page_size);
205
- require_once($this->views . 'list.php');
206
  }
207
 
208
  function get_form_sort_vars($params,$where_clause = ''){
@@ -265,18 +267,18 @@ class FrmFormsController{
265
  }
266
 
267
  function get_edit_vars($id, $errors = '', $message='', $create_link=false){
268
- global $frm_app_helper, $frm_field_selection, $frm_entry, $frm_form, $frm_field, $frm_recaptcha_enabled, $frm_pro_field_selection, $frm_utils, $frmpro_is_installed;
269
  $record = $frm_form->getOne( $id );
270
  $items = $frm_entry->getAll('',' ORDER BY it.name');
271
 
272
  $fields = $frm_field->getAll("fi.form_id=$id", ' ORDER BY field_order');
273
  $values = $frm_app_helper->setup_edit_vars($record,'forms',$fields,true);
274
- if ($values['default_template'])
275
  wp_die('That template cannot be edited');
276
  else if($create_link)
277
- require_once($this->views . 'new.php');
278
  else
279
- require_once($this->views . 'edit.php');
280
  }
281
 
282
  function get_params(){
9
  add_action('wp_ajax_frm_form_name_in_place_edit', array($this, 'edit_name') );
10
  add_action('wp_ajax_frm_form_desc_in_place_edit', array($this, 'edit_description') );
11
  add_action('wp_ajax_frm_delete_form_wo_fields',array($this, 'destroy_wo_fields'));
 
12
  }
13
 
14
  function menu(){
18
  }
19
 
20
  function head(){
21
+ $css_file = array('jquery-ui-1.7.2.custom' => FRM_URL.'/css/ui-lightness/jquery-ui-1.7.2.custom.css', 'frm_admin' => FRM_URL. '/css/frm_admin.css');
22
  $js_file = 'list-items.js';
23
  require_once(FRM_VIEWS_PATH . '/shared/head.php');
24
  }
43
  else if ($action == 'new'){
44
  $values = FrmFormsHelper::setup_new_vars();
45
  $id = $frm_form->create( $values );
46
+ require_once(FRM_VIEWS_PATH.'/frm-forms/new.php');
47
  }else{
48
  $all_templates = $frm_form->getAll('is_template=1',' ORDER BY name');
49
+ require_once(FRM_VIEWS_PATH.'/frm-forms/new-selection.php');
50
  }
51
  }
52
 
53
  function create(){
54
+ global $frm_app_controller, $frm_app_helper, $frm_field_selection, $frm_entry, $frm_form, $frm_field, $frm_recaptcha_enabled, $frm_pro_field_selection, $frmpro_is_installed;
55
  $errors = $frm_form->validate($_POST);
56
  $id = $frm_app_controller->get_param('id');
57
 
59
  $record = $frm_form->getOne( $id );
60
  $fields = $frm_field->getAll("fi.form_id=$id", ' ORDER BY field_order');
61
  $values = $frm_app_helper->setup_edit_vars($record,'forms',$fields,true);
62
+ require_once(FRM_VIEWS_PATH.'/frm-forms/new.php');
63
  }else{
64
  $items = $frm_entry->getAll('',' ORDER BY it.name');
65
  $record = $frm_form->update( $id, $_POST, true );
137
 
138
  header("Content-Type: text/html; charset=utf-8");
139
 
140
+ $plugin = FrmAppController::get_param('plugin');
141
+ $controller = FrmAppController::get_param('controller');
142
  $key = (isset($_GET['form'])?$_GET['form']:(isset($_POST['form'])?$_POST['form']:''));
143
  $form = $frm_form->getAll("form_key='$key'",'',' LIMIT 1');
144
  if (!$form) $form = $frm_form->getAll('','',' LIMIT 1');
145
+ $form_options = stripslashes_deep(maybe_unserialize($form->options));
146
+ $description = $title = true;
147
 
148
  require_once(FRM_VIEWS_PATH.'/frm-entries/direct.php');
149
  }
151
  function destroy(){
152
  global $frm_form;
153
  $params = $this->get_params();
154
+ $message = '';
155
  if ($frm_form->destroy( $params['id'] ))
156
  $message = "Form was Successfully Deleted";
157
  $this->display_forms_list($params, $message, '', 1);
158
  }
159
 
160
  function destroy_wo_fields(){
161
+ global $frm_field, $frm_form, $frm_app_helper;
162
  $id = $_POST['form_id'];
163
+ if ($frm_app_helper->getRecordCount('form_id='.$id, $frm_field->table_name) <= 0)
164
  $frm_form->destroy($id);
165
  die();
166
  }
167
 
168
  function display_forms_list($params=false, $message='', $page_params_ov = false, $current_page_ov = false, $errors = array()){
169
+ global $wpdb, $frm_app_helper, $frm_form, $frm_entry, $frm_page_size, $frmpro_is_installed;
170
 
171
  if(!$params)
172
  $params = $this->get_params();
199
  $sdir_str = $form_vars['sdir_str'];
200
  $search_str = $form_vars['search_str'];
201
 
202
+ $record_count = $frm_app_helper->getRecordCount($form_vars['where_clause'], $frm_form->table_name);
203
+ $page_count = $frm_app_helper->getPageCount($frm_page_size,$form_vars['where_clause'], $frm_form->table_name);
204
+ $forms = $frm_app_helper->getPage($current_page, $frm_page_size, $form_vars['where_clause'], $form_vars['order_by'], $frm_form->table_name);
205
+ $page_last_record = $frm_app_helper->getLastRecordNum($record_count,$current_page,$frm_page_size);
206
+ $page_first_record = $frm_app_helper->getFirstRecordNum($record_count,$current_page,$frm_page_size);
207
+ require_once(FRM_VIEWS_PATH.'/frm-forms/list.php');
208
  }
209
 
210
  function get_form_sort_vars($params,$where_clause = ''){
267
  }
268
 
269
  function get_edit_vars($id, $errors = '', $message='', $create_link=false){
270
+ global $frm_app_helper, $frm_field_selection, $frm_entry, $frm_form, $frm_field, $frm_recaptcha_enabled, $frm_pro_field_selection, $frmpro_is_installed;
271
  $record = $frm_form->getOne( $id );
272
  $items = $frm_entry->getAll('',' ORDER BY it.name');
273
 
274
  $fields = $frm_field->getAll("fi.form_id=$id", ' ORDER BY field_order');
275
  $values = $frm_app_helper->setup_edit_vars($record,'forms',$fields,true);
276
+ if (isset($values['default_template']) && $values['default_template'])
277
  wp_die('That template cannot be edited');
278
  else if($create_link)
279
+ require_once(FRM_VIEWS_PATH.'/frm-forms/new.php');
280
  else
281
+ require_once(FRM_VIEWS_PATH.'/frm-forms/edit.php');
282
  }
283
 
284
  function get_params(){
classes/controllers/FrmSettingsController.php CHANGED
@@ -3,32 +3,40 @@
3
  class FrmSettingsController{
4
  function FrmSettingsController(){
5
  add_action('admin_menu', array( $this, 'menu' ), 25);
6
- add_action('admin_head-'.FRM_PLUGIN_NAME.'-settings', array($this,'head'));
7
- $this->views = FRM_VIEWS_PATH.'/frm-settings/';
8
  }
9
 
10
  function menu(){
 
11
  add_submenu_page(FRM_PLUGIN_NAME, FRM_PLUGIN_TITLE .' | Settings', 'Settings', 8, FRM_PLUGIN_NAME.'-settings', array($this,'route'));
12
- //add_submenu_page(FRM_PLUGIN_NAME, FRM_PLUGIN_TITLE .' | '. FRM_PLUGIN_TITLE . ' Pro', FRM_PLUGIN_TITLE . ' Pro', 8, FRM_PLUGIN_NAME.'-pro-settings', array($this,'pro_settings'));
13
  }
14
 
15
  function head(){
16
- $css_file = 'frm_admin.css';
17
- $js_file = 'list-items.js';
18
- require_once(FRM_VIEWS_PATH . '/shared/admin_head.php');
 
 
 
 
 
 
 
 
 
19
  }
20
 
21
  function display_form(){
22
  global $frm_settings;
23
-
24
- require_once($this->views . 'form.php');
25
  }
26
 
27
  function process_form(){
28
  global $frm_settings;
29
 
30
- $errors = $frm_settings->validate($_POST,$errors);
31
-
32
  $frm_settings->update($_POST);
33
 
34
  if( empty($errors) ){
@@ -36,60 +44,7 @@ class FrmSettingsController{
36
  $message = 'Settings Saved';
37
  }
38
 
39
- require_once($this->views . 'form.php');
40
- }
41
-
42
- function pro_settings(){
43
- global $frm_utils, $frmpro_is_installed, $frm_app_controller;
44
-
45
- $action = $frm_app_controller->get_param('action');
46
- $errors = array();
47
-
48
- // variables for the field and option names
49
- $frmpro_username = 'frmpro_username';
50
- $frmpro_password = 'frmpro_password';
51
- $hidden_field_name = 'frm_update_options';
52
-
53
- // Read in existing option value from database
54
- $frmpro_username_val = get_option( $frmpro_username );
55
- $frmpro_password_val = get_option( $frmpro_password );
56
-
57
- if($action == 'force-pro-reinstall'){
58
- $frm_utils->download_and_install_pro($frmpro_username_val, $frmpro_password_val, true);
59
- $message = _e(FRM_PLUGIN_TITLE .' Pro Successfully Reinstalled.', FRM_PLUGIN_NAME );
60
- }else if($action == 'pro-uninstall'){
61
- $frm_utils->uninstall_pro();
62
- $message = _e(FRM_PLUGIN_TITLE .' Pro Successfully Uninstalled.', FRM_PLUGIN_NAME );
63
- }else{
64
- // See if the user has posted us some information
65
- // If they did, this hidden field will be set to 'Y'
66
- if( $frm_app_controller->get_param('$hidden_field_name') == 'Y' ){
67
- // Validate This
68
- // This is where the remote username / password will be validated
69
-
70
- // Read their posted value
71
- $prlipro_username_val = stripslashes($_POST[ $prlipro_username ]);
72
- $prlipro_password_val = stripslashes($_POST[ $prlipro_password ]);
73
-
74
- $user_type = $prli_utils->get_pro_user_type($prlipro_username_val, $prlipro_password_val);
75
- if(empty($user_type))
76
- $errors[] = "Your user account couldn't be validated...";
77
-
78
- if( count($errors) > 0 ){
79
- require(FRM_VIEWS_PATH.'/shared/errors.php');
80
- }else{
81
- // Save the posted value in the database
82
- update_option( $frmpro_username, $frmpro_username_val );
83
- update_option( $frmpro_password, $frmpro_password_val );
84
-
85
- // Put an options updated message on the screen
86
- $message = $prli_utils->download_and_install_pro($prlipro_username_val, $prlipro_password_val);
87
-
88
- $message = (($message == 'SUCCESS')?FRM_PLUGIN_TITLE. 'has been installed':$message);
89
- }
90
- }
91
- }
92
- require_once($this->views . 'pro-settings.php');
93
  }
94
 
95
  function route(){
3
  class FrmSettingsController{
4
  function FrmSettingsController(){
5
  add_action('admin_menu', array( $this, 'menu' ), 25);
6
+ add_action('admin_head-'.FRM_PLUGIN_NAME.'_page_'.FRM_PLUGIN_NAME.'-settings', array($this,'head'));
 
7
  }
8
 
9
  function menu(){
10
+ global $frm_update;
11
  add_submenu_page(FRM_PLUGIN_NAME, FRM_PLUGIN_TITLE .' | Settings', 'Settings', 8, FRM_PLUGIN_NAME.'-settings', array($this,'route'));
12
+ add_submenu_page(FRM_PLUGIN_NAME, FRM_PLUGIN_TITLE .' | '. FRM_PLUGIN_TITLE . ' Pro', FRM_PLUGIN_TITLE . ' Pro', 8, FRM_PLUGIN_NAME.'-pro-settings', array($frm_update,'pro_cred_form'));
13
  }
14
 
15
  function head(){
16
+ global $frm_settings;
17
+ $css_file = array($frm_settings->theme_nicename => $frm_settings->theme_css, 'frm_admin' => FRM_URL. '/css/frm_admin.css');
18
+ $js_file = 'jquery/jquery-ui-themepicker.js';
19
+ ?>
20
+ <link type="text/css" rel="stylesheet" href="http://jqueryui.com/themes/base/ui.all.css" />
21
+ <script>
22
+ jQuery(document).ready(function($){
23
+ $('#frm_switcher').themeswitcher();
24
+ });
25
+ </script>
26
+ <?php
27
+ require_once(FRM_VIEWS_PATH . '/shared/head.php');
28
  }
29
 
30
  function display_form(){
31
  global $frm_settings;
32
+ require_once(FRM_VIEWS_PATH . '/frm-settings/form.php');
 
33
  }
34
 
35
  function process_form(){
36
  global $frm_settings;
37
 
38
+ //$errors = $frm_settings->validate($_POST,array());
39
+ $errors = array();
40
  $frm_settings->update($_POST);
41
 
42
  if( empty($errors) ){
44
  $message = 'Settings Saved';
45
  }
46
 
47
+ require_once(FRM_VIEWS_PATH . '/frm-settings/form.php');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
  }
49
 
50
  function route(){
classes/controllers/FrmStatisticsController.php CHANGED
@@ -3,17 +3,16 @@
3
  class FrmStatisticsController{
4
  function FrmStatisticsController(){
5
  add_action('admin_menu', array( $this, 'menu' ), 30);
6
- $this->views = FRM_VIEWS_PATH.'/frm-statistics/';
7
  }
8
 
9
  function menu(){
10
  global $frmpro_is_installed;
11
  if(!$frmpro_is_installed)
12
- add_submenu_page(FRM_PLUGIN_TITLE, FRM_PLUGIN_TITLE .' | Pro Statistics', 'Pro Statistics', 8, FRM_PLUGIN_TITLE.'-statistics',array($this,''));
13
  }
14
 
15
  function list_entries(){
16
- require_once($this->views .'list.php');
17
  }
18
 
19
  }
3
  class FrmStatisticsController{
4
  function FrmStatisticsController(){
5
  add_action('admin_menu', array( $this, 'menu' ), 30);
 
6
  }
7
 
8
  function menu(){
9
  global $frmpro_is_installed;
10
  if(!$frmpro_is_installed)
11
+ add_submenu_page(FRM_PLUGIN_TITLE, FRM_PLUGIN_TITLE .' | Statistics', 'Statistics', 8, FRM_PLUGIN_TITLE.'-statistics',array($this,''));
12
  }
13
 
14
  function list_entries(){
15
+ require_once(FRM_VIEWS_PATH . '/frm-statistics/list.php');
16
  }
17
 
18
  }
classes/helpers/FrmAppHelper.php CHANGED
@@ -7,14 +7,19 @@ class FrmAppHelper{
7
  return get_posts( array('post_type' => 'page', 'post_status' => 'published', 'numberposts' => 99, 'order_by' => 'post_title', 'order' => 'ASC'));
8
  }
9
 
10
- function value_is_selected($field_name, $field_value, $selected_value){
11
- if( (isset($_POST[$field_name]) and $_POST[$field_name] == $selected_value) or (!isset($_POST[$field_name]) and $field_value == $selected_value) )
12
- echo ' selected="selected"';
13
- }
14
-
15
- function value_is_checked($field_name, $field_value){
16
- if( (isset($_POST) and $_POST[$field_name] == '1') or (!isset($_POST) and $field_value == '1') )
17
- echo ' checked="checked"';
 
 
 
 
 
18
  }
19
 
20
  function value_is_checked_with_array($field_name, $index, $field_value){
@@ -31,16 +36,19 @@ class FrmAppHelper{
31
  $key = base_convert( rand($min_slug_value,$max_slug_value), 10, 36 );
32
  }else
33
  $key = sanitize_title_with_dashes($name);
 
 
 
34
 
35
  $query = "SELECT $column FROM $table_name WHERE $column = %s AND ID != %d LIMIT 1";
36
  $key_check = $wpdb->get_var($wpdb->prepare($query, $key, $id));
37
- if ($key_check){
38
  $suffix = 2;
39
  do {
40
  $alt_post_name = substr($key, 0, 200-(strlen($suffix)+1)). "$suffix";
41
  $key_check = $wpdb->get_var($wpdb->prepare($query, $alt_post_name, $id));
42
  $suffix++;
43
- } while ($key_check);
44
  $key = $alt_post_name;
45
  }
46
  return $key;
@@ -56,8 +64,6 @@ class FrmAppHelper{
56
  foreach (array('name' => $record->name, 'description' => $record->description) as $var => $default_val)
57
  $values[$var] = stripslashes($frm_app_controller->get_param($var, $default_val));
58
 
59
- $values['form_name'] = ($record->form_id)?($frm_form->getName( $record->form_id )):('');
60
-
61
  $values['fields'] = array();
62
  if ($fields){
63
  foreach($fields as $field){
@@ -68,52 +74,76 @@ class FrmAppHelper{
68
  $meta_value = $frm_entry_meta->get_entry_meta_by_field($record->id, $field->id, true);
69
 
70
  $field_options = stripslashes_deep(unserialize($field->field_options));
71
-
72
  $new_value = (isset($_POST['item_meta'][$field->id])) ? $_POST['item_meta'][$field->id] : $meta_value;
73
- if ($field->type != 'checkbox')
74
- $new_value = stripslashes($new_value);
75
 
76
  $field_array = array('id' => $field->id,
77
  'value' => $new_value,
78
  'default_value' => stripslashes($field->default_value),
79
  'name' => stripslashes($field->name),
80
  'description' => stripslashes($field->description),
81
- 'type' => apply_filters('frm_field_type',$field->type),
82
  'options' => stripslashes_deep(unserialize($field->options)),
83
  'required' => $field->required,
84
  'field_key' => $field->field_key,
85
  'field_order' => $field->field_order,
86
  'form_id' => $field->form_id);
87
 
88
- foreach (array('size' => 75,'max' => '','label' => 'top','invalid' => '','required_indicator' => '*','blank' => '') as $opt => $default_opt)
89
  $field_array[$opt] = ($_POST and isset($_POST['field_options'][$opt.'_'.$field->id]) ) ? $_POST['field_options'][$opt.'_'.$field->id] : (isset($field_options[$opt]) ? $field_options[$opt]: $default_opt);
90
 
91
- $values['fields'][] = apply_filters('frm_setup_edit_fields_vars', $field_array, $field);
92
  }
93
- }
94
 
95
- if ($table == 'entries')
96
- $values = FrmEntriesHelper::setup_edit_vars( $values, $record );
97
- else if ($table == 'forms')
98
- $values = FrmFormsHelper::setup_edit_vars( $values, $record );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
99
 
100
- return $values;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101
  }
102
 
103
  function frm_get_main_message( $message = ''){
104
- /*
105
- global $frmpro_is_installed;
106
- include_once(ABSPATH."/wp-includes/class-IXR.php");
107
-
108
- if($frmpro_is_installed){
109
- $client = new IXR_Client('http://prettylinkpro.com/xmlrpc.php');
110
- if ($client->query('prlipro.get_main_message'))
111
- $message = $client->getResponse();
112
- }else{
113
- $client = new IXR_Client('http://blairwilliams.com/xmlrpc.php');
114
- if ($client->query('prli.get_main_message'))
115
- $message = $client->getResponse();
116
- } */
117
  return $message;
118
  }
119
 
@@ -129,14 +159,61 @@ END;
129
  COMMENT_FORM;
130
 
131
  $use_ssl = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") ? true : false;
132
-
133
- if (IS_WPMU){
134
- $error = $errors->get_error_message('captcha');
135
- echo($error ? '<p class="error">'.$error.'</p>' : '');
136
- }
137
  echo $format . recaptcha_wp_get_html(isset($_GET['rerror'])?$_GET['rerror']:'', $use_ssl);
138
  }
139
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
140
  }
141
 
142
  ?>
7
  return get_posts( array('post_type' => 'page', 'post_status' => 'published', 'numberposts' => 99, 'order_by' => 'post_title', 'order' => 'ASC'));
8
  }
9
 
10
+ function wp_pages_dropdown($field_name, $page_id){
11
+ global $frm_app_controller;
12
+
13
+ $field_value = $frm_app_controller->get_param($field_name);
14
+ $pages = get_posts( array('post_type' => 'page', 'post_status' => 'published', 'numberposts' => 99, 'order_by' => 'post_title', 'order' => 'ASC'));
15
+ ?>
16
+ <select name="<?php echo $field_name; ?>" id="<?php echo $field_name; ?>" class="frm-dropdown frm-pages-dropdown">
17
+ <option value=""></option>
18
+ <?php foreach($pages as $page){ ?>
19
+ <option value="<?php echo $page->ID; ?>" <?php echo (((isset($_POST[$field_name]) and $_POST[$field_name] == $page->ID) or (!isset($_POST[$field_name]) and $page_id == $page->ID))?' selected="selected"':''); ?>><?php echo $page->post_title; ?> </option>
20
+ <?php } ?>
21
+ </select>
22
+ <?php
23
  }
24
 
25
  function value_is_checked_with_array($field_name, $index, $field_value){
36
  $key = base_convert( rand($min_slug_value,$max_slug_value), 10, 36 );
37
  }else
38
  $key = sanitize_title_with_dashes($name);
39
+
40
+ if (is_numeric($key))
41
+ $key = $key .'a';
42
 
43
  $query = "SELECT $column FROM $table_name WHERE $column = %s AND ID != %d LIMIT 1";
44
  $key_check = $wpdb->get_var($wpdb->prepare($query, $key, $id));
45
+ if ($key_check || is_numeric($key_check)){
46
  $suffix = 2;
47
  do {
48
  $alt_post_name = substr($key, 0, 200-(strlen($suffix)+1)). "$suffix";
49
  $key_check = $wpdb->get_var($wpdb->prepare($query, $alt_post_name, $id));
50
  $suffix++;
51
+ } while ($key_check || is_numeric($key_check));
52
  $key = $alt_post_name;
53
  }
54
  return $key;
64
  foreach (array('name' => $record->name, 'description' => $record->description) as $var => $default_val)
65
  $values[$var] = stripslashes($frm_app_controller->get_param($var, $default_val));
66
 
 
 
67
  $values['fields'] = array();
68
  if ($fields){
69
  foreach($fields as $field){
74
  $meta_value = $frm_entry_meta->get_entry_meta_by_field($record->id, $field->id, true);
75
 
76
  $field_options = stripslashes_deep(unserialize($field->field_options));
77
+ $field_type = isset($_POST['field_options']['type_'.$field->id]) ? $_POST['field_options']['type_'.$field->id] : $field->type;
78
  $new_value = (isset($_POST['item_meta'][$field->id])) ? $_POST['item_meta'][$field->id] : $meta_value;
79
+ $new_value = stripslashes(maybe_unserialize($new_value));
 
80
 
81
  $field_array = array('id' => $field->id,
82
  'value' => $new_value,
83
  'default_value' => stripslashes($field->default_value),
84
  'name' => stripslashes($field->name),
85
  'description' => stripslashes($field->description),
86
+ 'type' => apply_filters('frm_field_type',$field_type, $field),
87
  'options' => stripslashes_deep(unserialize($field->options)),
88
  'required' => $field->required,
89
  'field_key' => $field->field_key,
90
  'field_order' => $field->field_order,
91
  'form_id' => $field->form_id);
92
 
93
+ foreach (array('size' => 50,'max' => '','label' => 'top','invalid' => '','required_indicator' => '*','blank' => '', 'clear_on_focus' => 0, 'custom_html' => FrmFieldsHelper::get_default_html($field), 'default_blank' => 0) as $opt => $default_opt)
94
  $field_array[$opt] = ($_POST and isset($_POST['field_options'][$opt.'_'.$field->id]) ) ? $_POST['field_options'][$opt.'_'.$field->id] : (isset($field_options[$opt]) ? $field_options[$opt]: $default_opt);
95
 
96
+ $values['fields'][] = apply_filters('frm_setup_edit_fields_vars', stripslashes_deep($field_array), $field, $values['id']);
97
  }
98
+ }
99
 
100
+ if ($table == 'entries')
101
+ $form = $frm_form->getOne( $record->form_id );
102
+ else if ($table == 'forms')
103
+ $form = $frm_form->getOne( $record->id );
104
+
105
+ if ($form){
106
+ $values['form_name'] = (isset($record->form_id))?($form->name):('');
107
+ $options = stripslashes_deep(unserialize($form->options));
108
+ if (is_array($options)){
109
+ foreach ($options as $opt => $value)
110
+ $values[$opt] = $frm_app_controller->get_param($opt, $value);
111
+ }
112
+ }
113
+
114
+ $email = get_option('admin_email');
115
+ foreach (array('email_to' => $email, 'submit_value' => 'Submit', 'success_msg' => 'Your responses were successfully submitted. Thank you!') as $opt => $default){
116
+ if (!isset($values[$opt]))
117
+ $values[$opt] = ($_POST and isset($_POST['options'][$opt])) ? $_POST['options'][$opt] : $default;
118
+ }
119
 
120
+ if (!isset($values['akismet']))
121
+ $values['akismet'] = ($_POST and isset($_POST['options']['akismet'])) ? 1 : 0;
122
+
123
+ if (!isset($values['before_html']))
124
+ $values['before_html'] = (isset($_POST['options']['before_html']) ? $_POST['options']['before_html'] : FrmFormsHelper::get_default_html('before'));
125
+
126
+ if (!isset($values['after_html']))
127
+ $values['after_html'] = (isset($_POST['options']['after_html'])?$_POST['options']['after_html'] : FrmFormsHelper::get_default_html('after'));
128
+
129
+ if ($table == 'entries')
130
+ $values = FrmEntriesHelper::setup_edit_vars( $values, $record );
131
+ else if ($table == 'forms')
132
+ $values = FrmFormsHelper::setup_edit_vars( $values, $record );
133
+
134
+ return $values;
135
  }
136
 
137
  function frm_get_main_message( $message = ''){
138
+ global $frmpro_is_installed;
139
+ include_once(ABSPATH."/wp-includes/class-IXR.php");
140
+
141
+ $url = ($frmpro_is_installed) ? 'http://formidablepro.com/' : 'http://blog.strategy11.com/';
142
+ $client = new IXR_Client($url.'xmlrpc.php');
143
+
144
+ if ($client->query('frm.get_main_message'))
145
+ $message = $client->getResponse();
146
+
 
 
 
 
147
  return $message;
148
  }
149
 
159
  COMMENT_FORM;
160
 
161
  $use_ssl = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") ? true : false;
162
+
 
 
 
 
163
  echo $format . recaptcha_wp_get_html(isset($_GET['rerror'])?$_GET['rerror']:'', $use_ssl);
164
  }
165
 
166
+ function truncate($str, $length, $minword = 3, $continue = '...'){
167
+ $sub = '';
168
+ $len = 0;
169
+
170
+ foreach (explode(' ', $str) as $word){
171
+ $part = (($sub != '') ? ' ' : '') . $word;
172
+ $sub .= $part;
173
+ $len += strlen($part);
174
+
175
+ if (strlen($word) > $minword && strlen($sub) >= $length)
176
+ break;
177
+ }
178
+
179
+ return $sub . (($len < strlen($str)) ? $continue : '');
180
+ }
181
+
182
+ function prepend_and_or_where( $starts_with = ' WHERE', $where = '' ){
183
+ return (( $where == '' )?'':$starts_with . $where);
184
+ }
185
+
186
+ // Pagination Methods
187
+ function getLastRecordNum($r_count,$current_p,$p_size){
188
+ return (($r_count < ($current_p * $p_size))?$r_count:($current_p * $p_size));
189
+ }
190
+
191
+ function getFirstRecordNum($r_count,$current_p,$p_size){
192
+ if($current_p == 1)
193
+ return 1;
194
+ else
195
+ return ($this->getLastRecordNum($r_count,($current_p - 1),$p_size) + 1);
196
+ }
197
+
198
+ function getRecordCount($where="", $table_name){
199
+ global $wpdb, $frm_app_helper;
200
+ $query = 'SELECT COUNT(*) FROM ' . $table_name . $frm_app_helper->prepend_and_or_where(' WHERE ', $where);
201
+ return $wpdb->get_var($query);
202
+ }
203
+
204
+ function getPageCount($p_size, $where="", $table_name){
205
+ return ceil((int)$this->getRecordCount($where, $table_name) / (int)$p_size);
206
+ }
207
+
208
+ function getPage($current_p,$p_size, $where = "", $order_by = '', $table_name){
209
+ global $wpdb, $frm_app_helper;
210
+ $end_index = $current_p * $p_size;
211
+ $start_index = $end_index - $p_size;
212
+ $query = 'SELECT * FROM ' . $table_name . $frm_app_helper->prepend_and_or_where(' WHERE', $where) . $order_by .' LIMIT ' . $start_index . ',' . $p_size;
213
+ $results = $wpdb->get_results($query);
214
+ return $results;
215
+ }
216
+
217
  }
218
 
219
  ?>
classes/helpers/FrmEntriesHelper.php CHANGED
@@ -12,39 +12,82 @@ class FrmEntriesHelper{
12
  if ($fields){
13
  foreach($fields as $field){
14
  $default = $field->default_value;
15
-
16
  $field_options = unserialize($field->field_options);
17
  $new_value = ($_POST and isset($_POST['item_meta'][$field->id])) ? $_POST['item_meta'][$field->id] : $default;
18
  if ($field->type != 'checkbox')
19
- $new_value = stripslashes($new_value);
20
 
21
  $field_array = array('id' => $field->id,
22
  'value' => $new_value,
23
  'default_value' => $new_value,
24
  'name' => stripslashes($field->name),
25
  'description' => stripslashes($field->description),
26
- 'type' => apply_filters('frm_field_type',$field->type),
27
- 'options' => unserialize($field->options),
28
  'required' => $field->required,
29
  'field_key' => $field->field_key,
30
  'field_order' => $field->field_order,
31
  'form_id' => $field->form_id);
32
-
33
- foreach (array('size' => 75,'max' => '','label' => 'top','invalid' => '','required_indicator' => '*','blank' => '') as $opt => $default_opt)
34
  $field_array[$opt] = (isset($field_options[$opt]) && $field_options[$opt] != '') ? $field_options[$opt] : $default_opt;
35
-
36
- $values['fields'][] = apply_filters('frm_setup_new_fields_vars', $field_array, $field);
 
 
 
 
 
 
 
 
 
 
37
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
  }
39
  return $values;
40
  }
41
 
42
  function setup_edit_vars($values, $record){
43
  //$values['description'] = unserialize( $record->description );
44
- $values['item_key'] = (($_POST and isset($_POST['item_key']) and $record == null)?$_POST['item_key']:$record->item_key);
45
- return $values;
 
46
  }
47
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
  }
49
 
50
  ?>
12
  if ($fields){
13
  foreach($fields as $field){
14
  $default = $field->default_value;
15
+
16
  $field_options = unserialize($field->field_options);
17
  $new_value = ($_POST and isset($_POST['item_meta'][$field->id])) ? $_POST['item_meta'][$field->id] : $default;
18
  if ($field->type != 'checkbox')
19
+ $new_value = apply_filters('frm_get_default_value', stripslashes($new_value));
20
 
21
  $field_array = array('id' => $field->id,
22
  'value' => $new_value,
23
  'default_value' => $new_value,
24
  'name' => stripslashes($field->name),
25
  'description' => stripslashes($field->description),
26
+ 'type' => apply_filters('frm_field_type',$field->type, $field),
27
+ 'options' => stripslashes_deep(unserialize($field->options)),
28
  'required' => $field->required,
29
  'field_key' => $field->field_key,
30
  'field_order' => $field->field_order,
31
  'form_id' => $field->form_id);
32
+
33
+ foreach (array('size' => 75,'max' => '','label' => 'top','invalid' => '','required_indicator' => '','blank' => '', 'clear_on_focus' => 0, 'custom_html' => FrmFieldsHelper::get_default_html($field), 'default_blank' => 0) as $opt => $default_opt)
34
  $field_array[$opt] = (isset($field_options[$opt]) && $field_options[$opt] != '') ? $field_options[$opt] : $default_opt;
35
+
36
+ $values['fields'][] = apply_filters('frm_setup_new_fields_vars', stripslashes_deep($field_array), $field);
37
+
38
+ if (!isset($form))
39
+ $form = $frm_form->getOne($field->form_id);
40
+ }
41
+
42
+ $options = stripslashes_deep(unserialize($form->options));
43
+
44
+ if (is_array($options)){
45
+ foreach ($options as $opt => $value)
46
+ $values[$opt] = $frm_app_controller->get_param($opt, $value);
47
  }
48
+ if (!isset($values['email_to']))
49
+ $values['email_to'] = '';
50
+
51
+ if (!isset($values['submit_value']))
52
+ $values['submit_value'] = 'Submit';
53
+
54
+ if (!isset($values['success_msg']))
55
+ $values['success_msg'] = 'Your responses were successfully submitted. Thank you!';
56
+
57
+ if (!isset($values['akismet']))
58
+ $values['akismet'] = 0;
59
+
60
+ if (!isset($values['before_html']))
61
+ $values['before_html'] = FrmFormsHelper::get_default_html('before');
62
+
63
+ if (!isset($values['after_html']))
64
+ $values['after_html'] = FrmFormsHelper::get_default_html('after');
65
  }
66
  return $values;
67
  }
68
 
69
  function setup_edit_vars($values, $record){
70
  //$values['description'] = unserialize( $record->description );
71
+ $values['item_key'] = ($_POST and isset($_POST['item_key']))?$_POST['item_key']:$record->item_key;
72
+ $values['form_id'] = $record->form_id;
73
+ return apply_filters('frm_setup_edit_entry_vars', $values);
74
  }
75
 
76
+ function entries_dropdown( $form_id, $field_name, $field_value='', $blank=true, $blank_label='' ){
77
+ global $frm_app_controller, $frm_entry;
78
+
79
+ $entries = $frm_entry->getAll("it.form_id=".$form_id,' ORDER BY name');
80
+ ?>
81
+ <select name="<?php echo $field_name; ?>" id="<?php echo $field_name; ?>" class="frm-dropdown">
82
+ <?php if ($blank){ ?>
83
+ <option value=""><?php echo $blank_label; ?></option>
84
+ <?php } ?>
85
+ <?php foreach($entries as $entry){ ?>
86
+ <option value="<?php echo $entry->id; ?>" <?php selected($field_value, $entry->id); ?>><?php echo (!empty($entry->name)) ? $entry->name : $entry->item_key; ?></option>
87
+ <?php } ?>
88
+ </select>
89
+ <?php
90
+ }
91
  }
92
 
93
  ?>
classes/helpers/FrmFieldsHelper.php CHANGED
@@ -3,9 +3,9 @@
3
  class FrmFieldsHelper{
4
 
5
  function setup_new_vars($type='',$form_id=''){
6
- global $frm_field;
7
 
8
- $field_count = $frm_field->getRecordCount("form_id=$form_id");
9
  $key = FrmAppHelper::get_unique_key('', $frm_field->table_name, 'field_key');
10
 
11
  $values = array();
@@ -13,13 +13,13 @@ class FrmFieldsHelper{
13
  $values[$var] = $default;
14
 
15
  $values['field_options'] = array();
16
- foreach (array('size' => '50', 'max' => '', 'label' => 'top', 'required_indicator' => '*') as $var => $default)
17
  $values['field_options'][$var] = $default;
18
 
19
  if ($type == 'radio' || ($type == 'checkbox'))
20
  $values['options'] = serialize(array(1 => 'Option 1', 2 => 'Option 2'));
21
  else if ( $type == 'select')
22
- $values['options'] = serialize(array(1 => '', 2 => 'Option 1', 3 => 'Option 2'));
23
  else if ($type == 'textarea'){
24
  $values['field_options']['size'] = '45';
25
  $values['field_options']['max'] = '5';
@@ -33,7 +33,7 @@ class FrmFieldsHelper{
33
 
34
  $values = array();
35
  $values['id'] = $record->id;
36
-
37
  foreach (array('name' => $record->name, 'description' => $record->description) as $var => $default)
38
  $values[$var] = htmlspecialchars(stripslashes($frm_app_controller->get_param($var, $default)));
39
 
@@ -51,10 +51,82 @@ class FrmFieldsHelper{
51
  $values['blank'] = (isset($field_options['blank']))?($field_options['blank']):('');
52
  $values['required_indicator'] = (isset($field_options['required_indicator']))?($field_options['required_indicator']):('*');
53
  $values['invalid'] = (isset($field_options['invalid']))?($field_options['invalid']):('');
 
 
 
54
 
55
  return $values;
56
  }
57
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
  }
59
 
60
  ?>
3
  class FrmFieldsHelper{
4
 
5
  function setup_new_vars($type='',$form_id=''){
6
+ global $frm_field, $frm_app_helper;
7
 
8
+ $field_count = $frm_app_helper->getRecordCount("form_id=$form_id", $frm_field->table_name);
9
  $key = FrmAppHelper::get_unique_key('', $frm_field->table_name, 'field_key');
10
 
11
  $values = array();
13
  $values[$var] = $default;
14
 
15
  $values['field_options'] = array();
16
+ foreach (array('size' => '50', 'max' => '', 'label' => 'top', 'required_indicator' => '*', 'clear_on_focus' => 0, 'custom_html' => FrmFieldsHelper::get_default_html($type), 'default_blank' => 0) as $var => $default)
17
  $values['field_options'][$var] = $default;
18
 
19
  if ($type == 'radio' || ($type == 'checkbox'))
20
  $values['options'] = serialize(array(1 => 'Option 1', 2 => 'Option 2'));
21
  else if ( $type == 'select')
22
+ $values['options'] = serialize(array(1 => '', 2 => 'Option 1'));
23
  else if ($type == 'textarea'){
24
  $values['field_options']['size'] = '45';
25
  $values['field_options']['max'] = '5';
33
 
34
  $values = array();
35
  $values['id'] = $record->id;
36
+ $values['form_id'] = $record->form_id;
37
  foreach (array('name' => $record->name, 'description' => $record->description) as $var => $default)
38
  $values[$var] = htmlspecialchars(stripslashes($frm_app_controller->get_param($var, $default)));
39
 
51
  $values['blank'] = (isset($field_options['blank']))?($field_options['blank']):('');
52
  $values['required_indicator'] = (isset($field_options['required_indicator']))?($field_options['required_indicator']):('*');
53
  $values['invalid'] = (isset($field_options['invalid']))?($field_options['invalid']):('');
54
+ $values['clear_on_focus'] = (isset($field_options['clear_on_focus']))?($field_options['clear_on_focus']):(0);
55
+ $values['default_blank'] = (isset($field_options['default_blank']))?($field_options['default_blank']):(0);
56
+ $values['custom_html'] = (isset($field_options['custom_html']))? stripslashes($field_options['custom_html']): FrmFieldsHelper::get_default_html($record->type);
57
 
58
  return $values;
59
  }
60
 
61
+ function get_default_html($type){
62
+ if (apply_filters('frm_show_normal_field_type', true, $type)){
63
+ $default_html = <<<DEFAULT_HTML
64
+ <div id="frm_field_[id]_container" class="form-field [required_class] [error_class]">
65
+ <label class="frm_pos_[label_position]">[field_name]
66
+ <span class="frm_required">[required_label]</span>
67
+ </label>
68
+ [input]
69
+ [if description]<p class="description">[description]</p>[/if description]
70
+ </div>
71
+ DEFAULT_HTML;
72
+ }else{
73
+ $default_html = apply_filters('frm_other_custom_html', '', $type);
74
+ }
75
+
76
+ return apply_filters('frm_custom_html', $default_html, $type);
77
+ }
78
+
79
+ function replace_shortcodes($html, $field, $error_keys=array()){
80
+ $field_name = "item_meta[". $field['id'] ."]";
81
+ //replace [id]
82
+ $html = str_replace('[id]', $field['id'], $html);
83
+
84
+ //replace [description] and [required_label]
85
+ $required = ($field['required'] == '0')?(''):($field['required_indicator']);
86
+ foreach (array('description' => $field['description'], 'required_label' => $required) as $code => $value){
87
+ if ($value == '')
88
+ $html = preg_replace('/(\[if\s+'.$code.'\])(.*?)(\[\/if\s+'.$code.'\])/mis', '', $html);
89
+ else{
90
+ $html = str_replace('[if '.$code.']','',$html);
91
+ $html = str_replace('[/if '.$code.']','',$html);
92
+ }
93
+ $html = str_replace('['.$code.']', $value, $html);
94
+ }
95
+
96
+ //replace [required_class]
97
+ $required_class = ($field['required'] == '0')?(''):(' form-required');
98
+ $html = str_replace('[required_class]', $required_class, $html);
99
+
100
+ //replace [label_position]
101
+ $html = str_replace('[label_position]', $field['label'], $html);
102
+
103
+ //replace [field_name]
104
+ $html = str_replace('[field_name]', $field['name'], $html);
105
+
106
+ //replace [error_class]
107
+ $error_class = in_array('field'.$field['id'], $error_keys) ? ' frm_blank_field':'';
108
+ $html = str_replace('[error_class]', $error_class, $html);
109
+
110
+ //replace [input]
111
+ ob_start();
112
+ include(FRM_VIEWS_PATH.'/frm-fields/input.php');
113
+ $contents = ob_get_contents();
114
+ ob_end_clean();
115
+ $html = str_replace('[input]', $contents, $html);
116
+
117
+ return $html;
118
+ }
119
+
120
+ function show_onfocus_js($field_id, $clear_on_focus){ ?>
121
+ <a href="javascript:frm_clear_on_focus(<?php echo $field_id; ?>,<?php echo $clear_on_focus; ?>)" class="<?php echo ($clear_on_focus) ?'':'frm_inactive_icon'; ?>" id="clear_field_<?php echo $field_id; ?>" title="Set this field to <?php echo ($clear_on_focus)?'not ':''; ?>clear on click"><img src="<?php echo FRM_IMAGES_URL?>/reload.png"></a>
122
+ <?php
123
+ }
124
+
125
+ function show_default_blank_js($field_id, $default_blank){ ?>
126
+ <a href="javascript:frm_default_blank(<?php echo $field_id; ?>,<?php echo $default_blank ?>)" class="<?php echo ($default_blank) ?'':'frm_inactive_icon'; ?>" id="default_blank_<?php echo $field_id; ?>" title="This default value should <?php echo ($default_blank)?'not ':''; ?>be considered blank"><img src="<?php echo FRM_IMAGES_URL?>/error.png"></a>
127
+ <?php
128
+ }
129
+
130
  }
131
 
132
  ?>
classes/helpers/FrmFormsHelper.php CHANGED
@@ -21,7 +21,25 @@ class FrmFormsHelper{
21
  <script type="text/javascript">
22
  function createFromFrmTemplate(form){window.location='<?php $_SERVER["REQUEST_URI"] ?>?page=<?php echo FRM_PLUGIN_NAME; ?>&action=duplicate&id='+form}
23
  </script>
24
- <?
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
  }
26
 
27
  function setup_new_vars(){
@@ -34,7 +52,12 @@ class FrmFormsHelper{
34
  $values[$var] = stripslashes($frm_app_controller->get_param($var, $default));
35
 
36
  $values['form_key'] = ($_POST and isset($_POST['form_key']))?$_POST['form_key']:(FrmAppHelper::get_unique_key('', $frm_form->table_name, 'form_key'));
37
- $values['email_to'] = ($_POST and isset($_POST['options']['email_to'])) ? $_POST['options']['email_to'] : '';
 
 
 
 
 
38
 
39
  return apply_filters('frm_setup_new_form_vars', $values);
40
  }
@@ -45,15 +68,40 @@ class FrmFormsHelper{
45
  $values['form_key'] = $frm_app_controller->get_param('form_key', $record->form_key);
46
  $values['default_template'] = $frm_app_controller->get_param('default_template', $record->default_template);
47
  $values['is_template'] = $frm_app_controller->get_param('is_template', $record->is_template);
48
- $options = stripslashes_deep(unserialize($record->options));
49
-
50
- if (is_array($options)){
51
- foreach ($options as $opt => $value)
52
- $values[$opt] = $frm_app_controller->get_param($opt, $value);
53
- }
54
 
55
  return apply_filters('frm_setup_edit_form_vars', $values);
56
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
 
58
  }
59
  ?>
21
  <script type="text/javascript">
22
  function createFromFrmTemplate(form){window.location='<?php $_SERVER["REQUEST_URI"] ?>?page=<?php echo FRM_PLUGIN_NAME; ?>&action=duplicate&id='+form}
23
  </script>
24
+ <?php
25
+ }
26
+
27
+ function forms_dropdown( $field_name, $field_value='', $blank=true, $field_id=false ){
28
+ global $frm_app_controller, $frm_form;
29
+ if (!$field_id)
30
+ $field_id = $field_name;
31
+
32
+ $forms = $frm_form->getAll("is_template=0 AND (status is NULL OR status = '' OR status = 'published')",' ORDER BY name');
33
+ ?>
34
+ <select name="<?php echo $field_name; ?>" id="<?php echo $field_id ?>" class="frm-dropdown">
35
+ <?php if ($blank){ ?>
36
+ <option value=""></option>
37
+ <?php } ?>
38
+ <?php foreach($forms as $form){ ?>
39
+ <option value="<?php echo $form->id; ?>" <?php selected($field_value, $form->id); ?>><?php echo $form->name; ?></option>
40
+ <?php } ?>
41
+ </select>
42
+ <?php
43
  }
44
 
45
  function setup_new_vars(){
52
  $values[$var] = stripslashes($frm_app_controller->get_param($var, $default));
53
 
54
  $values['form_key'] = ($_POST and isset($_POST['form_key']))?$_POST['form_key']:(FrmAppHelper::get_unique_key('', $frm_form->table_name, 'form_key'));
55
+ $values['email_to'] = ($_POST and isset($_POST['options']['email_to'])) ? $_POST['options']['email_to'] : get_option('admin_email');
56
+ $values['submit_value'] = ($_POST and isset($_POST['options']['submit_value'])) ? $_POST['options']['submit_value'] : 'Submit';
57
+ $values['success_msg'] = ($_POST and isset($_POST['options']['success_msg'])) ? $_POST['options']['success_msg'] : 'Your responses were successfully submitted. Thank you!';
58
+ $values['akismet'] = ($_POST and isset($_POST['options']['akismet'])) ? 1 : 0;
59
+ $values['before_html'] = FrmFormsHelper::get_default_html('before');
60
+ $values['after_html'] = FrmFormsHelper::get_default_html('after');
61
 
62
  return apply_filters('frm_setup_new_form_vars', $values);
63
  }
68
  $values['form_key'] = $frm_app_controller->get_param('form_key', $record->form_key);
69
  $values['default_template'] = $frm_app_controller->get_param('default_template', $record->default_template);
70
  $values['is_template'] = $frm_app_controller->get_param('is_template', $record->is_template);
 
 
 
 
 
 
71
 
72
  return apply_filters('frm_setup_edit_form_vars', $values);
73
  }
74
+
75
+ function get_default_html($loc){
76
+ if ($loc == 'before'){
77
+ $default_html = <<<BEFORE_HTML
78
+ [if form_name]<h3>[form_name]</h3>[/if form_name]
79
+ [if form_description]<p class="frm_description">[form_description]</p>[/if form_description]
80
+ BEFORE_HTML;
81
+ }else{
82
+ $default_html = '';
83
+ }
84
+ return $default_html;
85
+ }
86
+
87
+ function replace_shortcodes($html, $form, $title=false, $description=false){
88
+ foreach (array('form_name' => $title,'form_description' => $description) as $code => $show){
89
+ if ($code == 'form_name')
90
+ $replace_with = $form->name;
91
+ else if ($code == 'form_description')
92
+ $replace_with = $form->description;
93
+
94
+ if (($show == true || $show == 'true') && $replace_with != '' ){
95
+ $html = str_replace('[if '.$code.']','',$html);
96
+ $html = str_replace('[/if '.$code.']','',$html);
97
+ }else{
98
+ $html = preg_replace('/(\[if\s+'.$code.'\])(.*?)(\[\/if\s+'.$code.'\])/mis', '', $html);
99
+ }
100
+ $html = str_replace('['.$code.']', $replace_with, $html);
101
+ }
102
+
103
+ return $html;
104
+ }
105
 
106
  }
107
  ?>
classes/helpers/FrmSettingsHelper.php CHANGED
@@ -1,19 +1,5 @@
1
  <?php
2
 
3
  class FrmSettingsHelper{
4
- function wp_pages_dropdown($field_name, $page_id){
5
- global $frm_app_controller;
6
-
7
- $field_value = $frm_app_controller->get_param($field_name);
8
- $pages = get_posts( array('post_type' => 'page', 'post_status' => 'published', 'numberposts' => 99, 'order_by' => 'post_title', 'order' => 'ASC'));
9
- ?>
10
- <select name="<?php echo $field_name; ?>" id="<?php echo $field_name; ?>" class="frm-dropdown frm-pages-dropdown">
11
- <option value=""></option>
12
- <?php foreach($pages as $page){ ?>
13
- <option value="<?php echo $page->ID; ?>" <?php echo (((isset($_POST[$field_name]) and $_POST[$field_name] == $page->ID) or (!isset($_POST[$field_name]) and $page_id == $page->ID))?' selected="selected"':''); ?>><?php echo $page->post_title; ?> </option>
14
- <?php } ?>
15
- </select>
16
- <?php
17
- }
18
  }
19
  ?>
1
  <?php
2
 
3
  class FrmSettingsHelper{
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  }
5
  ?>
classes/models/FrmEntry.php CHANGED
@@ -9,7 +9,7 @@ class FrmEntry{
9
 
10
  function create( $values ){
11
  global $wpdb, $frm_entry_meta;
12
-
13
  $new_values = array();
14
  $new_values['item_key'] = FrmAppHelper::get_unique_key($values['item_key'], $this->table_name, 'item_key');
15
  $new_values['name'] = isset($values['name']) ? $values['name'] : $values['item_key'];
@@ -22,12 +22,11 @@ class FrmEntry{
22
 
23
  $query_results = $wpdb->insert( $this->table_name, $new_values );
24
 
25
- if($query_results){ //TODO: save checkbox values in serialized array
26
  $entry_id = $wpdb->insert_id;
27
  if (isset($values['item_meta']))
28
  $frm_entry_meta->update_entry_metas($entry_id, $values['item_meta']);
29
- $entry = $this->getOne($entry_id);
30
- do_action('frm_after_create_entry', $entry);
31
  return $entry_id;
32
  }else
33
  return false;
@@ -57,7 +56,10 @@ class FrmEntry{
57
  function update( $id, $values ){
58
  global $wpdb, $frm_entry_meta, $frm_field;
59
 
60
- $new_values = array();
 
 
 
61
  $new_values['name'] = isset($values['name'])?$values['name']:'';
62
  $new_values['form_id'] = isset($values['form_id'])?(int)$values['form_id']: null;
63
  //$new_values['parent_item_id'] = isset($values['parent_item_id'])?(int)$values['parent_item_id']: null;
@@ -66,7 +68,7 @@ class FrmEntry{
66
 
67
  if (isset($values['item_meta']))
68
  $frm_entry_meta->update_entry_metas($id, $values['item_meta']);
69
-
70
  return $query_results;
71
  }
72
 
@@ -101,31 +103,34 @@ class FrmEntry{
101
  function getOne( $id ){
102
  global $wpdb, $frm_form;
103
  $query = 'SELECT it.*, ' .
104
- 'gr.name as form_name, ' .
105
- 'gr.form_key as form_key ' .
106
  'FROM '. $this->table_name . ' it ' .
107
- 'LEFT OUTER JOIN ' . $frm_form->table_name . ' gr ON it.form_id=gr.id' .
108
- ' WHERE it.id=' . $id;
 
 
 
109
  return $wpdb->get_row($query);
110
  }
111
 
112
  function getAll($where = '', $order_by = '', $limit = ''){
113
- global $wpdb, $frm_form, $frm_utils;
114
  $query = 'SELECT it.*, ' .
115
- 'gr.name as form_name, ' .
116
- 'gr.form_key as form_key ' .
117
  'FROM '. $this->table_name . ' it ' .
118
- 'LEFT OUTER JOIN ' . $frm_form->table_name . ' gr ON it.form_id=gr.id' .
119
- $frm_utils->prepend_and_or_where(' WHERE ', $where) . $order_by . $limit;
120
  return $wpdb->get_results($query);
121
  }
122
 
123
  // Pagination Methods
124
  function getRecordCount($where=""){
125
- global $wpdb, $frm_utils, $frm_form;
126
  $query = 'SELECT COUNT(*) FROM ' . $this->table_name . ' it ' .
127
- 'LEFT OUTER JOIN ' . $frm_form->table_name . ' gr ON it.form_id=gr.id' .
128
- $frm_utils->prepend_and_or_where(' WHERE ', $where);
129
  return $wpdb->get_var($query);
130
  }
131
 
@@ -134,21 +139,21 @@ class FrmEntry{
134
  }
135
 
136
  function getPage($current_p,$p_size, $where = "", $order_by = ''){
137
- global $wpdb, $frm_utils, $frm_form;
138
  $end_index = $current_p * $p_size;
139
  $start_index = $end_index - $p_size;
140
  $query = 'SELECT it.*, ' .
141
- 'gr.name as form_name ' .
142
  'FROM ' . $this->table_name . ' it ' .
143
- 'LEFT OUTER JOIN ' . $frm_form->table_name . ' gr ON it.form_id=gr.id' .
144
- $frm_utils->prepend_and_or_where(' WHERE', $where) . $order_by . ' ' .
145
  'LIMIT ' . $start_index . ',' . $p_size . ';';
146
  $results = $wpdb->get_results($query);
147
  return $results;
148
  }
149
 
150
  function validate( $values ){
151
- global $wpdb, $frm_utils, $frm_field, $frm_entry_meta;
152
 
153
  $errors = array();
154
 
@@ -161,17 +166,16 @@ class FrmEntry{
161
  }
162
 
163
  if( !isset($values['item_key']) or $values['item_key'] == '' )
164
- $_POST['item_key'] = FrmAppHelper::get_unique_key('', $this->table_name, 'item_key');;
165
-
166
- //if( $values['name'] == null or $values['name'] == '' )
167
- // $errors[] = "Name can't be blank";
168
 
169
  if (isset($values['item_meta'])){
170
  foreach($values['item_meta'] as $key => $value){
171
  $field = $frm_field->getOne($key);
172
- if ($field->required == '1' and ($values['item_meta'][$key] == null or $values['item_meta'][$key] == '') and ($field->form_id == $values['form_id'])){
173
  $field_options = unserialize($field->field_options);
174
- $errors['field'.$field->id] = ($field_options['blank'] == 'Untitled cannot be blank' || $field_options['blank'] == '')?($field->name." can't be blank"):$field_options['blank'];
 
 
175
  }
176
  $errors = apply_filters('frm_validate_field_entry', $errors, $key, $value);
177
  }
@@ -193,8 +197,54 @@ class FrmEntry{
193
  }
194
  }
195
 
 
 
 
 
 
 
 
 
 
196
  return $errors;
197
  }
198
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
199
  }
200
  ?>
9
 
10
  function create( $values ){
11
  global $wpdb, $frm_entry_meta;
12
+
13
  $new_values = array();
14
  $new_values['item_key'] = FrmAppHelper::get_unique_key($values['item_key'], $this->table_name, 'item_key');
15
  $new_values['name'] = isset($values['name']) ? $values['name'] : $values['item_key'];
22
 
23
  $query_results = $wpdb->insert( $this->table_name, $new_values );
24
 
25
+ if($query_results){
26
  $entry_id = $wpdb->insert_id;
27
  if (isset($values['item_meta']))
28
  $frm_entry_meta->update_entry_metas($entry_id, $values['item_meta']);
29
+ do_action('frm_after_create_entry', $entry_id);
 
30
  return $entry_id;
31
  }else
32
  return false;
56
  function update( $id, $values ){
57
  global $wpdb, $frm_entry_meta, $frm_field;
58
 
59
+ $new_values = array();
60
+ if (isset($values['item_key']))
61
+ $new_values['item_key'] = FrmAppHelper::get_unique_key($values['item_key'], $this->table_name, 'item_key', $id);
62
+
63
  $new_values['name'] = isset($values['name'])?$values['name']:'';
64
  $new_values['form_id'] = isset($values['form_id'])?(int)$values['form_id']: null;
65
  //$new_values['parent_item_id'] = isset($values['parent_item_id'])?(int)$values['parent_item_id']: null;
68
 
69
  if (isset($values['item_meta']))
70
  $frm_entry_meta->update_entry_metas($id, $values['item_meta']);
71
+ do_action('frm_after_update_entry', $id);
72
  return $query_results;
73
  }
74
 
103
  function getOne( $id ){
104
  global $wpdb, $frm_form;
105
  $query = 'SELECT it.*, ' .
106
+ 'fr.name as form_name, ' .
107
+ 'fr.form_key as form_key ' .
108
  'FROM '. $this->table_name . ' it ' .
109
+ 'LEFT OUTER JOIN ' . $frm_form->table_name . ' fr ON it.form_id=fr.id';
110
+ if(is_numeric($id))
111
+ $query .= ' WHERE it.id=' . $id;
112
+ else
113
+ $query .= " WHERE it.item_key='" . $id ."'";
114
  return $wpdb->get_row($query);
115
  }
116
 
117
  function getAll($where = '', $order_by = '', $limit = ''){
118
+ global $wpdb, $frm_form, $frm_app_helper;
119
  $query = 'SELECT it.*, ' .
120
+ 'fr.name as form_name, ' .
121
+ 'fr.form_key as form_key ' .
122
  'FROM '. $this->table_name . ' it ' .
123
+ 'LEFT OUTER JOIN ' . $frm_form->table_name . ' fr ON it.form_id=fr.id' .
124
+ $frm_app_helper->prepend_and_or_where(' WHERE ', $where) . $order_by . $limit;
125
  return $wpdb->get_results($query);
126
  }
127
 
128
  // Pagination Methods