Formidable Forms – Form Builder for WordPress - Version 1.05.05

Version Description

  • Added Dutch translation (Eric Horstman)
  • Fixed "Customize Form HTML" link issues some users were having
  • PRO: Load jQuery UI javascript for datepicker
  • PRO: Fixed custom display "where" options to work with multiple where rows
Download this release

Release Info

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

Code changes from version 1.04.07 to 1.05.05

Files changed (65) hide show
  1. classes/controllers/FrmApiController.php +1 -4
  2. classes/controllers/FrmAppController.php +86 -34
  3. classes/controllers/FrmEntriesController.php +21 -15
  4. classes/controllers/FrmFieldsController.php +124 -23
  5. classes/controllers/FrmFormsController.php +33 -39
  6. classes/controllers/FrmSettingsController.php +6 -6
  7. classes/controllers/FrmStatisticsController.php +2 -2
  8. classes/helpers/FrmAppHelper.php +270 -49
  9. classes/helpers/FrmEntriesHelper.php +46 -33
  10. classes/helpers/FrmFieldsHelper.php +80 -35
  11. classes/helpers/FrmFormsHelper.php +11 -13
  12. classes/models/FrmDb.php +181 -152
  13. classes/models/FrmEntry.php +129 -92
  14. classes/models/FrmEntryMeta.php +20 -17
  15. classes/models/FrmField.php +38 -17
  16. classes/models/FrmForm.php +51 -29
  17. classes/models/FrmNotification.php +16 -9
  18. classes/models/FrmSettings.php +23 -8
  19. classes/models/FrmUpdate.php +15 -13
  20. classes/templates/contact.php +19 -12
  21. classes/views/frm-entries/direct.php +4 -4
  22. classes/views/frm-entries/errors.php +36 -0
  23. classes/views/frm-entries/form.php +16 -20
  24. classes/views/frm-entries/frm-entry.php +12 -11
  25. classes/views/frm-entries/list.php +2 -2
  26. classes/views/frm-entries/new.php +2 -2
  27. classes/views/frm-fields/import_choices.php +86 -0
  28. classes/views/frm-fields/input.php +37 -19
  29. classes/views/frm-fields/show.php +1 -1
  30. classes/views/frm-fields/single-option.php +1 -2
  31. classes/views/frm-forms/add_field.php +61 -23
  32. classes/views/frm-forms/add_field_links.php +10 -5
  33. classes/views/frm-forms/default-templates.php +5 -3
  34. classes/views/frm-forms/edit.php +8 -5
  35. classes/views/frm-forms/footer.php +1 -1
  36. classes/views/frm-forms/form.php +17 -12
  37. classes/views/frm-forms/insert_form_popup.php +1 -1
  38. classes/views/frm-forms/list.php +32 -21
  39. classes/views/frm-forms/new-field-js.php +11 -10
  40. classes/views/frm-forms/new-option-js.php +11 -12
  41. classes/views/frm-forms/new-selection.php +2 -3
  42. classes/views/frm-forms/new.php +8 -2
  43. classes/views/frm-settings/form.php +48 -25
  44. classes/views/frm-statistics/list.php +2 -2
  45. classes/views/shared/item-table-nav.php +8 -11
  46. classes/views/shared/nav.php +10 -9
  47. classes/views/shared/pagination.php +11 -8
  48. classes/widgets/FrmShowForm.php +64 -0
  49. css/frm_admin.css +20 -10
  50. css/frm_display.css +19 -19
  51. formidable.php +43 -36
  52. images/ajax_loader.gif +0 -0
  53. images/form_16.png +0 -0
  54. images/form_32.png +0 -0
  55. images/grey_bg.png +0 -0
  56. images/report_icon.png +0 -0
  57. js/formidable.js +176 -240
  58. js/formidable_admin.js +186 -0
  59. js/jquery/jquery-ui-themepicker.js +1 -1
  60. languages/formidable-en_US.po +2572 -983
  61. languages/formidable-nl_NL.mo +0 -0
  62. languages/formidable-nl_NL.po +5348 -0
  63. languages/formidable-pt_BR.mo +0 -0
  64. languages/formidable-pt_BR.po +2574 -985
  65. readme.txt +114 -4
classes/controllers/FrmApiController.php CHANGED
@@ -4,8 +4,6 @@
4
  */
5
 
6
  class FrmApiController{
7
- function FrmApiController(){
8
- }
9
 
10
  /********* DISPLAY DATA *************/
11
  function frm_filter_content($args){
@@ -29,8 +27,7 @@ class FrmApiController{
29
  global $frm_entry, $frm_form, $frm_entry_meta;
30
 
31
  $defaults = array(
32
- 'form_key' => '',
33
- 'order' => '', 'limit' => '',
34
  'search' =>'', 'search_type' => '',
35
  'search_field' => '', 'search_operator' => 'LIKE'
36
  );
4
  */
5
 
6
  class FrmApiController{
 
 
7
 
8
  /********* DISPLAY DATA *************/
9
  function frm_filter_content($args){
27
  global $frm_entry, $frm_form, $frm_entry_meta;
28
 
29
  $defaults = array(
30
+ 'form_key' => '', 'order' => '', 'limit' => '',
 
31
  'search' =>'', 'search_type' => '',
32
  'search_field' => '', 'search_operator' => 'LIKE'
33
  );
classes/controllers/FrmAppController.php CHANGED
@@ -9,21 +9,24 @@ class FrmAppController{
9
  add_action('admin_head', array(&$this, 'menu_css'));
10
  add_filter('frm_nav_array', array( &$this, 'frm_nav'), 1);
11
  add_filter('plugin_action_links_'.FRM_PLUGIN_NAME.'/'.FRM_PLUGIN_NAME.'.php', array( &$this, 'settings_link'), 10, 2 );
12
- add_action('after_plugin_row_'.FRM_PLUGIN_NAME.'/'.FRM_PLUGIN_NAME.'.php', array( &$this,'pro_action_needed'));
13
- add_action('admin_notices', array( &$this,'pro_get_started_headline'));
14
  add_filter('the_content', array( &$this, 'page_route' ), 1);
15
  add_action('init', array(&$this, 'front_head'));
16
- add_action('wp_footer', array(&$this, 'footer_js'), 1);
17
  add_action('admin_init', array( &$this, 'admin_js'));
18
- register_activation_hook(FRM_PATH."/formidable.php", array( &$this, 'install' ));
 
19
  add_action('wp_ajax_frm_uninstall', array(&$this, 'uninstall') );
20
 
21
  // Used to process standalone requests
22
- add_action('init', array(&$this,'parse_standalone_request'));
 
 
23
 
24
  //Shortcodes
25
- add_shortcode('formidable', array(&$this,'get_form_shortcode'));
26
- add_filter( 'widget_text', array(&$this,'widget_text_filter'), 9 );
27
  }
28
 
29
  function menu(){
@@ -32,35 +35,33 @@ class FrmAppController{
32
  $frm_roles = FrmAppHelper::frm_capabilities();
33
  foreach($frm_roles as $frm_role => $frm_role_description)
34
  $current_user->add_cap( $frm_role );
 
 
 
35
  }
36
  global $frmpro_is_installed;
37
  if(current_user_can('frm_view_forms')){
38
  global $frm_forms_controller;
39
- add_object_page(FRM_PLUGIN_TITLE, FRM_PLUGIN_TITLE, 'frm_view_forms', FRM_PLUGIN_NAME, array($frm_forms_controller,'route'), 'div');
40
  }elseif(current_user_can('frm_view_entries') and $frmpro_is_installed){
41
  global $frmpro_entries_controller;
42
- add_object_page(FRM_PLUGIN_TITLE, FRM_PLUGIN_TITLE, 'frm_view_entries', FRM_PLUGIN_NAME, array($frmpro_entries_controller,'route'), 'div');
43
  }
44
  }
45
 
46
  function menu_css(){ ?>
47
  <style type="text/css">
48
- #adminmenu .toplevel_page_formidable div.wp-menu-image{background: url(<?php echo FRM_IMAGES_URL ?>/icon_16_bw.png) no-repeat center;}
49
- #adminmenu .toplevel_page_formidable:hover div.wp-menu-image{background: url(<?php echo FRM_IMAGES_URL ?>/icon_16.png) no-repeat center;}
50
  </style>
51
  <?php
 
52
  }
53
 
54
- function frm_nav(){
55
- $nav = array();
56
- if(current_user_can('frm_view_forms'))
57
  $nav[FRM_PLUGIN_NAME] = __('Forms', 'formidable');
58
-
59
- if(current_user_can('frm_edit_forms'))
60
- $nav[FRM_PLUGIN_NAME . '-new'] = __('Create a Form', 'formidable');
61
-
62
- if(current_user_can('frm_view_forms'))
63
  $nav[FRM_PLUGIN_NAME . '-templates'] = __('Templates', 'formidable');
 
64
  return $nav;
65
  }
66
 
@@ -76,12 +77,12 @@ class FrmAppController{
76
  global $frm_update;
77
 
78
  if( $frm_update->pro_is_authorized() and !$frm_update->pro_is_installed() ){
79
- if (IS_WPMU and $frm_update->pro_wpmu and !is_site_admin())
80
  return;
81
  $frm_update->queue_update(true);
82
  $inst_install_url = wp_nonce_url('update.php?action=upgrade-plugin&plugin=' . $plugin, 'upgrade-plugin_' . $plugin);
83
  ?>
84
- <td colspan="3" class="plugin-update"><div class="update-message" style="-moz-border-radius:5px; border:1px solid #CC0000;; margin:5px; background-color:#FFEBE8; padding:3px 5px;"><?php printf(__('Your Formidable Pro installation isn\'t quite complete yet.<br/>%1$sAutomatically Upgrade to Enable Formidable Pro%2$s', 'formidable'), '<a href="'.$inst_install_url.'">', '</a>'); ?></div></td>
85
  <?php
86
  }
87
  }
@@ -93,16 +94,24 @@ class FrmAppController{
93
  if(isset($_GET['action']) and $_GET['action'] == 'upgrade-plugin')
94
  return;
95
 
96
- if (IS_WPMU and $frm_update->pro_wpmu and !is_site_admin())
97
  return;
98
 
99
  if(!isset($_GET['activate'])){
100
- global $frmpro_is_installed, $frm_db_version;
101
  $db_version = get_option('frm_db_version');
102
  $pro_db_version = ($frmpro_is_installed) ? get_option('frmpro_db_version') : false;
103
- if((int)$db_version < (int)$frm_db_version or ($pro_db_version and (int)$pro_db_version < 4)){ //this number should match the db_version in FrmDb.php
104
  ?>
105
- <div class="error" style="padding:7px;"><?php _e('Your Formidable database needs to be updated.<br/>Please deactivate and reactivate the plugin to fix this.', 'formidable'); ?></div>
 
 
 
 
 
 
 
 
106
  <?php
107
  }
108
  }
@@ -111,7 +120,7 @@ class FrmAppController{
111
  $frm_update->queue_update(true);
112
  $inst_install_url = wp_nonce_url('update.php?action=upgrade-plugin&plugin=' . $frm_update->plugin_name, 'upgrade-plugin_' . $frm_update->plugin_name);
113
  ?>
114
- <div class="error" style="padding:7px;"><?php printf(__('Your Formidable Pro installation isn\'t quite complete yet.<br/>%1$sAutomatically Upgrade to Enable Formidable Pro%2$s', 'formidable'), '<a href="'.$inst_install_url.'">','</a>'); ?></div>
115
  <?php
116
  }
117
  }
@@ -120,11 +129,12 @@ class FrmAppController{
120
  global $frm_version;
121
  wp_enqueue_script('jquery');
122
  wp_enqueue_script('jquery-ui-core');
123
- if(!(isset($_GET) and isset($_GET['page'])) or (isset($_GET['page']) and preg_match('/formidable*/', $_GET['page'])))
124
- wp_enqueue_script('jquery-tools', FRM_URL.'/js/jquery/jquery.tools.min.js', array('jquery'), '1.1.2');
125
  if(isset($_GET) and isset($_GET['page']) and preg_match('/formidable*/', $_GET['page'])){
 
126
  wp_enqueue_script('jquery-ui-sortable');
127
  wp_enqueue_script('jquery-ui-draggable');
 
128
  wp_enqueue_script('formidable', FRM_URL . '/js/formidable.js', array('jquery'), $frm_version);
129
  wp_enqueue_style('formidable-admin', FRM_URL. '/css/frm_admin.css', $frm_version);
130
  wp_enqueue_script('jquery-elastic', FRM_URL.'/js/jquery/jquery.elastic.js', array('jquery'));
@@ -139,7 +149,7 @@ class FrmAppController{
139
  //$frm_db_version is the version of the database we're moving to
140
  $old_db_version = get_option('frm_db_version');
141
  if ((int)$frm_db_version != (int)$old_db_version)
142
- $this->install();
143
  }
144
  wp_enqueue_script('jquery');
145
 
@@ -148,8 +158,11 @@ class FrmAppController{
148
  if(is_array($css)){
149
  foreach($css as $css_key => $file)
150
  wp_enqueue_style('frm-forms'.$css_key, $file, array(), $frm_version);
 
 
151
  }else
152
  wp_enqueue_style('frm-forms', $css, array(), $frm_version);
 
153
 
154
  global $frm_css_loaded;
155
  $frm_css_loaded = true;
@@ -157,7 +170,7 @@ class FrmAppController{
157
  }
158
 
159
  function footer_js($location='footer'){
160
- global $frm_load_css, $frm_settings, $frm_version, $frm_css_loaded;
161
 
162
  if($frm_load_css and !is_admin() and ($frm_settings->load_style != 'none')){
163
  if($frm_css_loaded)
@@ -171,20 +184,26 @@ class FrmAppController{
171
  foreach($css as $css_key => $file){
172
  echo 'jQuery("head").append(unescape("%3Clink rel=\'stylesheet\' id=\'frm-forms'. ($css_key + $frm_css_loaded) .'-css\' href=\''. $file. '\' type=\'text/css\' media=\'all\' /%3E"));';
173
  //wp_enqueue_style('frm-forms'.$css_key, $file, array(), $frm_version);
 
 
174
  }
175
  }else{
176
  echo 'jQuery("head").append(unescape("%3Clink rel=\'stylesheet\' id=\'frm-forms-css\' href=\''. $css. '\' type=\'text/css\' media=\'all\' /%3E"));';
177
  }
 
178
 
179
  //wp_enqueue_style('frm-forms', $css, array(), $frm_version);
180
  echo '</script>'."\n";
181
  }
182
  }
 
 
 
183
  }
184
 
185
- function install(){
186
  global $frmdb;
187
- $frmdb->upgrade();
188
  }
189
 
190
  function uninstall(){
@@ -210,6 +229,37 @@ class FrmAppController{
210
 
211
  return $content;
212
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
213
 
214
  // The tight way to process standalone requests dogg...
215
  function parse_standalone_request(){
@@ -225,10 +275,12 @@ class FrmAppController{
225
 
226
  // Routes for standalone / ajax requests
227
  function standalone_route($controller, $action=''){
228
- global $frm_forms_controller;
229
 
230
- if($controller=='forms' and !in_array($action, array('export','import','xml')))
231
  $frm_forms_controller->preview($this->get_param('form'));
 
 
232
  else
233
  do_action('frm_standalone_route', $controller, $action);
234
  }
9
  add_action('admin_head', array(&$this, 'menu_css'));
10
  add_filter('frm_nav_array', array( &$this, 'frm_nav'), 1);
11
  add_filter('plugin_action_links_'.FRM_PLUGIN_NAME.'/'.FRM_PLUGIN_NAME.'.php', array( &$this, 'settings_link'), 10, 2 );
12
+ add_action('after_plugin_row_'.FRM_PLUGIN_NAME.'/'.FRM_PLUGIN_NAME.'.php', array( &$this, 'pro_action_needed'));
13
+ add_action('admin_notices', array( &$this, 'pro_get_started_headline'));
14
  add_filter('the_content', array( &$this, 'page_route' ), 1);
15
  add_action('init', array(&$this, 'front_head'));
16
+ add_action('wp_footer', array(&$this, 'footer_js'), 1, 0);
17
  add_action('admin_init', array( &$this, 'admin_js'));
18
+ register_activation_hook(FRM_PATH.'/formidable.php', array( &$this, 'install' ));
19
+ add_action('wp_ajax_frm_install', array(&$this, 'install') );
20
  add_action('wp_ajax_frm_uninstall', array(&$this, 'uninstall') );
21
 
22
  // Used to process standalone requests
23
+ add_action('init', array(&$this, 'parse_standalone_request'));
24
+ // Update the session data
25
+ add_action('init', array(&$this, 'referer_session'), 1);
26
 
27
  //Shortcodes
28
+ add_shortcode('formidable', array(&$this, 'get_form_shortcode'));
29
+ add_filter( 'widget_text', array(&$this, 'widget_text_filter'), 9 );
30
  }
31
 
32
  function menu(){
35
  $frm_roles = FrmAppHelper::frm_capabilities();
36
  foreach($frm_roles as $frm_role => $frm_role_description)
37
  $current_user->add_cap( $frm_role );
38
+ unset($frm_roles);
39
+ unset($frm_role);
40
+ unset($frm_role_description);
41
  }
42
  global $frmpro_is_installed;
43
  if(current_user_can('frm_view_forms')){
44
  global $frm_forms_controller;
45
+ add_object_page(FRM_PLUGIN_TITLE, FRM_PLUGIN_TITLE, 'frm_view_forms', FRM_PLUGIN_NAME, array($frm_forms_controller, 'route'), 'div');
46
  }elseif(current_user_can('frm_view_entries') and $frmpro_is_installed){
47
  global $frmpro_entries_controller;
48
+ add_object_page(FRM_PLUGIN_TITLE, FRM_PLUGIN_TITLE, 'frm_view_entries', FRM_PLUGIN_NAME, array($frmpro_entries_controller, 'route'), 'div');
49
  }
50
  }
51
 
52
  function menu_css(){ ?>
53
  <style type="text/css">
54
+ #adminmenu .toplevel_page_formidable div.wp-menu-image{background: url(<?php echo FRM_IMAGES_URL ?>/form_16.png) no-repeat center;}
 
55
  </style>
56
  <?php
57
+ //#adminmenu .toplevel_page_formidable:hover div.wp-menu-image{background: url(<?php echo FRM_IMAGES_URL /icon_16.png) no-repeat center;}
58
  }
59
 
60
+ function frm_nav($nav=array()){
61
+ if(current_user_can('frm_view_forms')){
 
62
  $nav[FRM_PLUGIN_NAME] = __('Forms', 'formidable');
 
 
 
 
 
63
  $nav[FRM_PLUGIN_NAME . '-templates'] = __('Templates', 'formidable');
64
+ }
65
  return $nav;
66
  }
67
 
77
  global $frm_update;
78
 
79
  if( $frm_update->pro_is_authorized() and !$frm_update->pro_is_installed() ){
80
+ if (IS_WPMU and $frm_update->pro_wpmu and !FrmAppHelper::is_super_admin())
81
  return;
82
  $frm_update->queue_update(true);
83
  $inst_install_url = wp_nonce_url('update.php?action=upgrade-plugin&plugin=' . $plugin, 'upgrade-plugin_' . $plugin);
84
  ?>
85
+ <td colspan="3" class="plugin-update"><div class="update-message" style="-moz-border-radius:5px;border:1px solid #CC0000;; margin:5px;background-color:#FFEBE8;padding:3px 5px;"><?php printf(__('Your Formidable Pro installation isn\'t quite complete yet.<br/>%1$sAutomatically Upgrade to Enable Formidable Pro%2$s', 'formidable'), '<a href="'.$inst_install_url.'">', '</a>'); ?></div></td>
86
  <?php
87
  }
88
  }
94
  if(isset($_GET['action']) and $_GET['action'] == 'upgrade-plugin')
95
  return;
96
 
97
+ if (IS_WPMU and !current_user_can('administrator'))
98
  return;
99
 
100
  if(!isset($_GET['activate'])){
101
+ global $frmpro_is_installed, $frm_db_version, $frm_ajax_url;
102
  $db_version = get_option('frm_db_version');
103
  $pro_db_version = ($frmpro_is_installed) ? get_option('frmpro_db_version') : false;
104
+ if((int)$db_version < (int)$frm_db_version or ($frmpro_is_installed and (int)$pro_db_version < 9)){ //this number should match the db_version in FrmDb.php
105
  ?>
106
+ <div class="error" id="frm_install_message" style="padding:7px;"><?php _e('Your Formidable database needs to be updated.<br/>Please deactivate and reactivate the plugin to fix this or', 'formidable'); ?> <a id="frm_install_link" href="javascript:frm_install_now()"><?php _e('Update Now', 'formidable') ?></a></div>
107
+ <script type="text/javascript">
108
+ function frm_install_now(){
109
+ jQuery('#frm_install_link').replaceWith('<img src="<?php echo FRM_IMAGES_URL; ?>/wpspin_light.gif" alt="<?php _e('Loading...', 'formidable'); ?>" />');
110
+ jQuery.ajax({type:"POST",url:"<?php echo $frm_ajax_url ?>",data:"action=frm_install",
111
+ success:function(msg){jQuery("#frm_install_message").fadeOut("slow");}
112
+ });
113
+ };
114
+ </script>
115
  <?php
116
  }
117
  }
120
  $frm_update->queue_update(true);
121
  $inst_install_url = wp_nonce_url('update.php?action=upgrade-plugin&plugin=' . $frm_update->plugin_name, 'upgrade-plugin_' . $frm_update->plugin_name);
122
  ?>
123
+ <div class="error" style="padding:7px;"><?php printf(__('Your Formidable Pro installation isn\'t quite complete yet.<br/>%1$sAutomatically Upgrade to Enable Formidable Pro%2$s', 'formidable'), '<a href="'.$inst_install_url.'">', '</a>'); ?></div>
124
  <?php
125
  }
126
  }
129
  global $frm_version;
130
  wp_enqueue_script('jquery');
131
  wp_enqueue_script('jquery-ui-core');
132
+
 
133
  if(isset($_GET) and isset($_GET['page']) and preg_match('/formidable*/', $_GET['page'])){
134
+ wp_enqueue_script('jquery-tools', FRM_URL.'/js/jquery/jquery.tools.min.js', array('jquery'), '1.1.2');
135
  wp_enqueue_script('jquery-ui-sortable');
136
  wp_enqueue_script('jquery-ui-draggable');
137
+ wp_enqueue_script('formidable_admin', FRM_URL . '/js/formidable_admin.js', array('jquery'), $frm_version);
138
  wp_enqueue_script('formidable', FRM_URL . '/js/formidable.js', array('jquery'), $frm_version);
139
  wp_enqueue_style('formidable-admin', FRM_URL. '/css/frm_admin.css', $frm_version);
140
  wp_enqueue_script('jquery-elastic', FRM_URL.'/js/jquery/jquery.elastic.js', array('jquery'));
149
  //$frm_db_version is the version of the database we're moving to
150
  $old_db_version = get_option('frm_db_version');
151
  if ((int)$frm_db_version != (int)$old_db_version)
152
+ $this->install($old_db_version);
153
  }
154
  wp_enqueue_script('jquery');
155
 
158
  if(is_array($css)){
159
  foreach($css as $css_key => $file)
160
  wp_enqueue_style('frm-forms'.$css_key, $file, array(), $frm_version);
161
+ unset($css_key);
162
+ unset($file);
163
  }else
164
  wp_enqueue_style('frm-forms', $css, array(), $frm_version);
165
+ unset($css);
166
 
167
  global $frm_css_loaded;
168
  $frm_css_loaded = true;
170
  }
171
 
172
  function footer_js($location='footer'){
173
+ global $frm_load_css, $frm_settings, $frm_version, $frm_css_loaded, $frm_forms_loaded;
174
 
175
  if($frm_load_css and !is_admin() and ($frm_settings->load_style != 'none')){
176
  if($frm_css_loaded)
184
  foreach($css as $css_key => $file){
185
  echo 'jQuery("head").append(unescape("%3Clink rel=\'stylesheet\' id=\'frm-forms'. ($css_key + $frm_css_loaded) .'-css\' href=\''. $file. '\' type=\'text/css\' media=\'all\' /%3E"));';
186
  //wp_enqueue_style('frm-forms'.$css_key, $file, array(), $frm_version);
187
+ unset($css_key);
188
+ unset($file);
189
  }
190
  }else{
191
  echo 'jQuery("head").append(unescape("%3Clink rel=\'stylesheet\' id=\'frm-forms-css\' href=\''. $css. '\' type=\'text/css\' media=\'all\' /%3E"));';
192
  }
193
+ unset($css);
194
 
195
  //wp_enqueue_style('frm-forms', $css, array(), $frm_version);
196
  echo '</script>'."\n";
197
  }
198
  }
199
+
200
+ if(!is_admin() and $location != 'header' and !empty($frm_forms_loaded)) //load formidable js
201
+ echo '<script type="text/javascript" src="'. FRM_URL .'/js/formidable.js?ver='.$frm_version.'"></script>'."\n";
202
  }
203
 
204
+ function install($old_db_version=false){
205
  global $frmdb;
206
+ $frmdb->upgrade($old_db_version);
207
  }
208
 
209
  function uninstall(){
229
 
230
  return $content;
231
  }
232
+
233
+ function referer_session() {
234
+ global $frm_siteurl, $frm_settings;
235
+
236
+ if(!isset($frm_settings->track) or !$frm_settings->track)
237
+ return;
238
+
239
+ if ( !isset($_SESSION) )
240
+ session_start();
241
+
242
+ if ( !isset($_SESSION['frm_http_pages']) or !is_array($_SESSION['frm_http_pages']) )
243
+ $_SESSION['frm_http_pages'] = array();
244
+
245
+ if ( !isset($_SESSION['frm_http_referer']) or !is_array($_SESSION['frm_http_referer']) )
246
+ $_SESSION['frm_http_referer'] = array();
247
+
248
+ if (!isset($_SERVER['HTTP_REFERER']) or (isset($_SERVER['HTTP_REFERER']) and (strpos($_SERVER['HTTP_REFERER'], $frm_siteurl) === false) and ! (in_array($_SERVER['HTTP_REFERER'], $_SESSION['frm_http_referer'])) )) {
249
+ if (! isset($_SERVER['HTTP_REFERER']))
250
+ $_SESSION['frm_http_referer'][] = "Type-in or bookmark";
251
+ else
252
+ $_SESSION['frm_http_referer'][] = $_SERVER['HTTP_REFERER'];
253
+ }
254
+
255
+ if ($_SESSION['frm_http_pages'] and !empty($_SESSION['frm_http_pages']) and (end($_SESSION['frm_http_pages']) != "http://". $_SERVER['SERVER_NAME']. $_SERVER['REQUEST_URI']))
256
+ $_SESSION['frm_http_pages'][] = "http://". $_SERVER['SERVER_NAME']. $_SERVER['REQUEST_URI'];
257
+
258
+ if(count($_SESSION['frm_http_pages']) > 100){
259
+ $first = reset($_SESSION['frm_http_pages']);
260
+ unset($first);
261
+ }
262
+ }
263
 
264
  // The tight way to process standalone requests dogg...
265
  function parse_standalone_request(){
275
 
276
  // Routes for standalone / ajax requests
277
  function standalone_route($controller, $action=''){
278
+ global $frm_forms_controller, $frm_fields_controller;
279
 
280
+ if($controller == 'forms' and !in_array($action, array('export', 'import', 'xml')))
281
  $frm_forms_controller->preview($this->get_param('form'));
282
+ else if($controller == 'fields' and $action == 'import_choices')
283
+ $frm_fields_controller->import_choices($this->get_param('field_id'));
284
  else
285
  do_action('frm_standalone_route', $controller, $action);
286
  }
classes/controllers/FrmEntriesController.php CHANGED
@@ -12,32 +12,32 @@ class FrmEntriesController{
12
  function menu(){
13
  global $frmpro_is_installed;
14
  if(!$frmpro_is_installed){
15
- add_submenu_page(FRM_PLUGIN_NAME, FRM_PLUGIN_TITLE .' |'. __('Pro Entries', 'formidable'), __('Pro Entries', 'formidable'), 'administrator', FRM_PLUGIN_NAME.'-entries',array($this,'list_entries'));
16
- //add_action('admin_head-'.FRM_PLUGIN_NAME.'_page_'.FRM_PLUGIN_NAME.'-entries', array($this,'head'));
17
  }
18
  }
19
 
20
  function list_entries(){
21
- require_once(FRM_VIEWS_PATH.'/frm-entries/list.php');
22
  }
23
 
24
  function show_form($id='', $key='', $title=false, $description=false){
25
  global $frm_form, $user_ID;
26
  if ($id) $form = $frm_form->getOne($id);
27
  else if ($key) $form = $frm_form->getOne($key);
28
-
29
- if (!$form or $form->is_template or $form->status == 'draft')
30
  return __('Please select a valid form', 'formidable');
31
- else if ($form->logged_in and !$user_ID){
32
  global $frm_settings;
33
  return $frm_settings->login_msg;
34
  }
35
-
36
- $form_options = stripslashes_deep(maybe_unserialize($form->options));
37
- if($form->logged_in and $user_ID and isset($form_options['logged_in_role']) and $form_options['logged_in_role'] != ''){
38
- if(FrmAppHelper::user_has_permission($form_options['logged_in_role']))
39
  return FrmEntriesController::get_form(FRM_VIEWS_PATH.'/frm-entries/frm-entry.php', $form, $title, $description);
40
- else{
41
  global $frm_settings;
42
  return $frm_settings->login_msg;
43
  }
@@ -60,7 +60,7 @@ class FrmEntriesController{
60
  global $frm_form;
61
 
62
  if(!$form)
63
- $form = $frm_form->getAll('',' ORDER BY name',' LIMIT 1');
64
 
65
  $action = apply_filters('frm_show_new_entry_page', FrmAppHelper::get_param('action', 'new'), $form);
66
  $default_values = array('id' => '', 'form_name' => '', 'paged' => 1, 'form' => $form->id, 'form_id' => $form->id, 'field_id' => '', 'search' => '', 'sort' => '', 'sdir' => '', 'action' => $action);
@@ -70,11 +70,17 @@ class FrmEntriesController{
70
  $values['posted_form_id'] = FrmAppHelper::get_param('form');
71
 
72
  if ($form->id == $values['posted_form_id']){ //if there are two forms on the same page, make sure not to submit both
73
- foreach ($default_values as $var => $default)
74
- $values[$var] = FrmAppHelper::get_param($var, $default);
 
 
 
75
  }else{
76
- foreach ($default_values as $var => $default)
77
  $values[$var] = $default;
 
 
 
78
  }
79
 
80
  return $values;
12
  function menu(){
13
  global $frmpro_is_installed;
14
  if(!$frmpro_is_installed){
15
+ add_submenu_page(FRM_PLUGIN_NAME, FRM_PLUGIN_TITLE .' |'. __('Pro Entries', 'formidable'), __('Pro Entries', 'formidable'), 'administrator', FRM_PLUGIN_NAME.'-entries',array(&$this, 'list_entries'));
16
+ //add_action('admin_head-'.FRM_PLUGIN_NAME.'_page_'.FRM_PLUGIN_NAME.'-entries', array(&$this, 'head'));
17
  }
18
  }
19
 
20
  function list_entries(){
21
+ require(FRM_VIEWS_PATH.'/frm-entries/list.php');
22
  }
23
 
24
  function show_form($id='', $key='', $title=false, $description=false){
25
  global $frm_form, $user_ID;
26
  if ($id) $form = $frm_form->getOne($id);
27
  else if ($key) $form = $frm_form->getOne($key);
28
+
29
+ if (!$form or $form->is_template or $form->status == 'draft'){
30
  return __('Please select a valid form', 'formidable');
31
+ }else if ($form->logged_in and !$user_ID){
32
  global $frm_settings;
33
  return $frm_settings->login_msg;
34
  }
35
+
36
+ $form->options = stripslashes_deep(maybe_unserialize($form->options));
37
+ if($form->logged_in and $user_ID and isset($form->options['logged_in_role']) and $form->options['logged_in_role'] != ''){
38
+ if(FrmAppHelper::user_has_permission($form->options['logged_in_role'])){
39
  return FrmEntriesController::get_form(FRM_VIEWS_PATH.'/frm-entries/frm-entry.php', $form, $title, $description);
40
+ }else{
41
  global $frm_settings;
42
  return $frm_settings->login_msg;
43
  }
60
  global $frm_form;
61
 
62
  if(!$form)
63
+ $form = $frm_form->getAll('', ' ORDER BY name', ' LIMIT 1');
64
 
65
  $action = apply_filters('frm_show_new_entry_page', FrmAppHelper::get_param('action', 'new'), $form);
66
  $default_values = array('id' => '', 'form_name' => '', 'paged' => 1, 'form' => $form->id, 'form_id' => $form->id, 'field_id' => '', 'search' => '', 'sort' => '', 'sdir' => '', 'action' => $action);
70
  $values['posted_form_id'] = FrmAppHelper::get_param('form');
71
 
72
  if ($form->id == $values['posted_form_id']){ //if there are two forms on the same page, make sure not to submit both
73
+ foreach ($default_values as $var => $default){
74
+ $values[$var] = FrmAppHelper::get_param($var, $default);
75
+ unset($var);
76
+ unset($default);
77
+ }
78
  }else{
79
+ foreach ($default_values as $var => $default){
80
  $values[$var] = $default;
81
+ unset($var);
82
+ unset($default);
83
+ }
84
  }
85
 
86
  return $values;
classes/controllers/FrmFieldsController.php CHANGED
@@ -16,16 +16,20 @@ class FrmFieldsController{
16
  add_action('wp_ajax_frm_add_field_option',array(&$this, 'add_option'));
17
  add_action('wp_ajax_frm_field_option_ipe', array(&$this, 'edit_option') );
18
  add_action('wp_ajax_frm_delete_field_option',array(&$this, 'delete_option'));
 
19
  add_action('wp_ajax_frm_update_field_order', array(&$this, 'update_order') );
20
- add_filter('frm_field_type',array( &$this, 'change_type'));
21
  add_filter('frm_display_field_options', array(&$this, 'display_field_options'));
22
- add_action('frm_field_input_html', array(&$this,'input_html'));
23
  }
24
 
25
  function create(){
26
  global $frm_field, $frm_ajax_url;
27
  $field_data = $_POST['field'];
28
  $form_id = $_POST['form_id'];
 
 
 
29
 
30
  $field_values = apply_filters('frm_before_field_created', FrmFieldsHelper::setup_new_vars($field_data, $form_id));
31
 
@@ -70,18 +74,18 @@ class FrmFieldsController{
70
  function clear_on_focus(){
71
  global $frm_field;
72
  $field = $frm_field->getOne($_POST['field']);
73
- $field_options = unserialize($field->field_options);
74
- $field_options['clear_on_focus'] = $_POST['active'];
75
- $frm_field->update($_POST['field'], array('field_options' => $field_options));
76
  die();
77
  }
78
 
79
  function default_blank(){
80
  global $frm_field;
81
  $field = $frm_field->getOne($_POST['field']);
82
- $field_options = unserialize($field->field_options);
83
- $field_options['default_blank'] = $_POST['active'];
84
- $frm_field->update($_POST['field'], array('field_options' => $field_options));
85
  die();
86
  }
87
 
@@ -93,11 +97,11 @@ class FrmFieldsController{
93
 
94
  $values = array();
95
  $values['field_key'] = FrmAppHelper::get_unique_key('', $frmdb->fields, 'field_key');
96
- $values['field_options'] = unserialize($copy_field->field_options);
97
  $values['form_id'] = $copy_field->form_id;
98
- foreach (array('name','description','type','default_value','options','required') as $col)
99
  $values[$col] = $copy_field->{$col};
100
- $field_count = $frm_app_helper->getRecordCount("form_id=$copy_field->form_id", $frmdb->fields);
101
  $values['field_order'] = $field_count + 1;
102
 
103
  $field_id = $frm_field->create($values);
@@ -124,7 +128,7 @@ class FrmFieldsController{
124
 
125
  $id = $_POST['field_id'];
126
  $field = $frm_field->getOne($id);
127
- $options = unserialize($field->options);
128
  if(!empty($options))
129
  $last = max(array_keys($options));
130
  else
@@ -132,7 +136,7 @@ class FrmFieldsController{
132
  $opt_key = $last + 1;
133
  $opt = 'Option '.(count($options)+1);
134
  $options[$opt_key] = $opt;
135
- $frm_field->update($id, array('options' => serialize($options)));
136
  $checked = '';
137
 
138
  $field_data = $frm_field->getOne($id);
@@ -151,7 +155,7 @@ class FrmFieldsController{
151
  $ids = explode('-',$_POST['element_id']);
152
  $id = str_replace('field_', '', $ids[0]);
153
  $field = $frm_field->getOne($id);
154
- $options = unserialize($field->options);
155
  $options[$ids[1]] = $_POST['update_value'];
156
  $frm_field->update($id, array('options' => maybe_serialize($options)));
157
  echo stripslashes($_POST['update_value']);
@@ -161,17 +165,109 @@ class FrmFieldsController{
161
  function delete_option(){
162
  global $frm_field;
163
  $field = $frm_field->getOne($_POST['field_id']);
164
- $options = unserialize($field->options);
165
  unset($options[$_POST['opt_key']]);
166
- $frm_field->update($_POST['field_id'], array('options' => serialize($options)));
167
  die();
168
  }
169
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
170
 
171
  function update_order(){
172
- global $frm_field;
173
- foreach ($_POST['frm_field_id'] as $position => $item)
174
- $frm_field->update($item, array('field_order' => $position));
 
 
 
175
  die();
176
  }
177
 
@@ -196,6 +292,7 @@ class FrmFieldsController{
196
  function display_field_options($display){
197
  if ($display['type'] == 'captcha'){
198
  $display['required'] = false;
 
199
  $display['default_blank'] = false;
200
  }else if ($display['type'] == 'radio'){
201
  $display['default_blank'] = false;
@@ -211,40 +308,44 @@ class FrmFieldsController{
211
  }
212
 
213
  function input_html($field){
 
 
214
  $class = $field['type'];
215
  if($field['type'] == 'date')
216
  $class .= " frm_date";
217
 
218
  if(isset($field['size']) and $field['size'] > 0){
219
- if($field['type'] != 'textarea' and $field['type'] != 'select')
220
  echo ' size="'. $field['size'] .'"';
221
  $class .= " auto_width";
222
  }
223
 
224
- if(isset($field['max']) and !in_array($field['type'], array('textarea','rte')) and !empty($field['max']))
225
  echo ' maxlength="'. $field['max'] .'"';
226
 
227
  if(!is_admin() or !isset($_GET) or !isset($_GET['page']) or $_GET['page'] == 'formidable_entries'){
228
  $action = FrmAppHelper::get_param('action');
229
  if(isset($field['required']) and $field['required']){
230
  //echo ' required="required"';
 
231
  if($field['type'] == 'file' and $action == 'edit'){
232
  //don't add the required class if this is a file upload when editing
233
  }else
234
  $class .= " required";
235
  }
236
 
237
- if(isset($field['default_value']) and !empty($field['default_value']) and !in_array($field['type'], array('select','radio','checkbox','hidden')))
238
  echo ' placeholder="'.$field['default_value'].'"';
239
 
240
  if(isset($field['clear_on_focus']) and $field['clear_on_focus']){
241
- echo ' onfocus="frmClearDefault(\''.$field['default_value'].'\', this)" onblur="frmReplaceDefault(\''.$field['default_value'].'\', this)"';
242
 
243
  if($field['value'] == $field['default_value'])
244
  echo ' style="font-style:italic;"';
245
  }
246
  }
247
 
 
248
  echo ' class="'.$class.'"';
249
  }
250
  }
16
  add_action('wp_ajax_frm_add_field_option',array(&$this, 'add_option'));
17
  add_action('wp_ajax_frm_field_option_ipe', array(&$this, 'edit_option') );
18
  add_action('wp_ajax_frm_delete_field_option',array(&$this, 'delete_option'));
19
+ add_action('wp_ajax_frm_import_options', array(&$this, 'import_options') );
20
  add_action('wp_ajax_frm_update_field_order', array(&$this, 'update_order') );
21
+ add_filter('frm_field_type' ,array( &$this, 'change_type'));
22
  add_filter('frm_display_field_options', array(&$this, 'display_field_options'));
23
+ add_action('frm_field_input_html', array(&$this, 'input_html'));
24
  }
25
 
26
  function create(){
27
  global $frm_field, $frm_ajax_url;
28
  $field_data = $_POST['field'];
29
  $form_id = $_POST['form_id'];
30
+ $values = array();
31
+ if(class_exists('FrmProForm'))
32
+ $values['post_type'] = FrmProForm::post_type($form_id);
33
 
34
  $field_values = apply_filters('frm_before_field_created', FrmFieldsHelper::setup_new_vars($field_data, $form_id));
35
 
74
  function clear_on_focus(){
75
  global $frm_field;
76
  $field = $frm_field->getOne($_POST['field']);
77
+ $field->field_options = maybe_unserialize($field->field_options);
78
+ $field->field_options['clear_on_focus'] = $_POST['active'];
79
+ $frm_field->update($_POST['field'], array('field_options' => $field->field_options));
80
  die();
81
  }
82
 
83
  function default_blank(){
84
  global $frm_field;
85
  $field = $frm_field->getOne($_POST['field']);
86
+ $field->field_options = maybe_unserialize($field->field_options);
87
+ $field->field_options['default_blank'] = $_POST['active'];
88
+ $frm_field->update($_POST['field'], array('field_options' => $field->field_options));
89
  die();
90
  }
91
 
97
 
98
  $values = array();
99
  $values['field_key'] = FrmAppHelper::get_unique_key('', $frmdb->fields, 'field_key');
100
+ $values['field_options'] = maybe_unserialize($copy_field->field_options);
101
  $values['form_id'] = $copy_field->form_id;
102
+ foreach (array('name', 'description', 'type', 'default_value', 'options', 'required') as $col)
103
  $values[$col] = $copy_field->{$col};
104
+ $field_count = $frm_app_helper->getRecordCount("form_id='$copy_field->form_id'", $frmdb->fields);
105
  $values['field_order'] = $field_count + 1;
106
 
107
  $field_id = $frm_field->create($values);
128
 
129
  $id = $_POST['field_id'];
130
  $field = $frm_field->getOne($id);
131
+ $options = maybe_unserialize($field->options);
132
  if(!empty($options))
133
  $last = max(array_keys($options));
134
  else
136
  $opt_key = $last + 1;
137
  $opt = 'Option '.(count($options)+1);
138
  $options[$opt_key] = $opt;
139
+ $frm_field->update($id, array('options' => maybe_serialize($options)));
140
  $checked = '';
141
 
142
  $field_data = $frm_field->getOne($id);
155
  $ids = explode('-',$_POST['element_id']);
156
  $id = str_replace('field_', '', $ids[0]);
157
  $field = $frm_field->getOne($id);
158
+ $options = maybe_unserialize($field->options);
159
  $options[$ids[1]] = $_POST['update_value'];
160
  $frm_field->update($id, array('options' => maybe_serialize($options)));
161
  echo stripslashes($_POST['update_value']);
165
  function delete_option(){
166
  global $frm_field;
167
  $field = $frm_field->getOne($_POST['field_id']);
168
+ $options = maybe_unserialize($field->options);
169
  unset($options[$_POST['opt_key']]);
170
+ $frm_field->update($_POST['field_id'], array('options' => maybe_serialize($options)));
171
  die();
172
  }
173
 
174
+ function import_choices($field_id){
175
+ if(!current_user_can('frm_edit_forms'))
176
+ return;
177
+
178
+ global $frm_ajax_url;
179
+
180
+ if(function_exists('register_admin_color_schemes'))
181
+ register_admin_color_schemes();
182
+
183
+ $hook_suffix = $admin_body_class = '';
184
+
185
+ if ( get_user_setting('mfold') == 'f' )
186
+ $admin_body_class .= ' folded';
187
+
188
+ if ( is_admin_bar_showing() )
189
+ $admin_body_class .= ' admin-bar';
190
+
191
+ if ( is_rtl() )
192
+ $admin_body_class .= ' rtl';
193
+
194
+ $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' );
195
+ $prepop = array();
196
+ $prepop[__('Countries', 'formidable')] = FrmAppHelper::get_countries();
197
+
198
+ $states = FrmAppHelper::get_us_states();
199
+ $prepop[__('U.S. States', 'formidable')] = array_values($states);
200
+ $prepop[__('U.S. State Abbreviations', 'formidable')] = array_keys($states);
201
+
202
+ $prepop[__('Age', 'formidable')] = array(
203
+ __('Under 18', 'formidable'), __('18-24', 'formidable'), __('25-34', 'formidable'),
204
+ __('35-44', 'formidable'), __('45-54', 'formidable'), __('55-64', 'formidable'),
205
+ __('65 or Above', 'formidable'), __('Prefer Not to Answer', 'formidable')
206
+ );
207
+
208
+ $prepop[__('Satisfaction', 'formidable')] = array(
209
+ __('Very Satisfied', 'formidable'), __('Satisfied', 'formidable'), __('Neutral', 'formidable'),
210
+ __('Unsatisfied', 'formidable'), __('Very Unsatisfied', 'formidable'), __('N/A', 'formidable')
211
+ );
212
+
213
+ $prepop[__('Importance', 'formidable')] = array(
214
+ __('Very Important', 'formidable'), __('Important', 'formidable'), __('Neutral', 'formidable'),
215
+ __('Somewhat Important', 'formidable'), __('Not at all Important', 'formidable'), __('N/A', 'formidable')
216
+ );
217
+
218
+ $prepop[__('Agreement', 'formidable')] = array(
219
+ __('Strongly Agree', 'formidable'), __('Agree', 'formidable'), __('Neutral', 'formidable'),
220
+ __('Disagree', 'formidable'), __('Strongly Disagree', 'formidable'), __('N/A', 'formidable')
221
+ );
222
+
223
+ $field = FrmField::getOne($field_id);
224
+ $field->options = maybe_unserialize($field->options);
225
+
226
+ include(FRM_VIEWS_PATH.'/frm-fields/import_choices.php');
227
+ die();
228
+ }
229
+
230
+ function import_options(){
231
+ if(!is_admin() or !current_user_can('frm_edit_forms'))
232
+ return;
233
+
234
+ global $frm_field, $frm_ajax_url;
235
+
236
+ extract($_POST);
237
+
238
+ $field = $frm_field->getOne($field_id);
239
+
240
+ if(!in_array($field->type, array('radio', 'checkbox', 'select')))
241
+ return;
242
+
243
+ $opts = stripslashes($opts);
244
+ $opts = explode("\n", rtrim($opts, "\n"));
245
+ $frm_field->update($field_id, array('options' => maybe_serialize($opts)));
246
+
247
+ $field = FrmFieldsHelper::setup_edit_vars($field);
248
+ $field['options'] = $opts;
249
+ $field_name = $field['name'];
250
+
251
+ if ($field['type'] == 'radio' or $field['type'] == 'checkbox'){
252
+ require(FRM_VIEWS_PATH.'/frm-fields/radio.php');
253
+ }else{
254
+ foreach ($field['options'] as $opt_key => $opt)
255
+ require(FRM_VIEWS_PATH.'/frm-fields/single-option.php');
256
+ }
257
+
258
+ $partial_js = true;
259
+ require(FRM_VIEWS_PATH.'/frm-forms/new-field-js.php');
260
+
261
+ die();
262
+ }
263
 
264
  function update_order(){
265
+ if(isset($_POST) and isset($_POST['frm_field_id'])){
266
+ global $frm_field;
267
+
268
+ foreach ($_POST['frm_field_id'] as $position => $item)
269
+ $frm_field->update($item, array('field_order' => $position));
270
+ }
271
  die();
272
  }
273
 
292
  function display_field_options($display){
293
  if ($display['type'] == 'captcha'){
294
  $display['required'] = false;
295
+ $display['invalid'] = true;
296
  $display['default_blank'] = false;
297
  }else if ($display['type'] == 'radio'){
298
  $display['default_blank'] = false;
308
  }
309
 
310
  function input_html($field){
311
+ global $frm_settings;
312
+
313
  $class = $field['type'];
314
  if($field['type'] == 'date')
315
  $class .= " frm_date";
316
 
317
  if(isset($field['size']) and $field['size'] > 0){
318
+ if($field['type'] != 'textarea' and $field['type'] != 'select' and $field['type'] != 'data')
319
  echo ' size="'. $field['size'] .'"';
320
  $class .= " auto_width";
321
  }
322
 
323
+ if(isset($field['max']) and !in_array($field['type'], array('textarea', 'rte')) and !empty($field['max']))
324
  echo ' maxlength="'. $field['max'] .'"';
325
 
326
  if(!is_admin() or !isset($_GET) or !isset($_GET['page']) or $_GET['page'] == 'formidable_entries'){
327
  $action = FrmAppHelper::get_param('action');
328
  if(isset($field['required']) and $field['required']){
329
  //echo ' required="required"';
330
+
331
  if($field['type'] == 'file' and $action == 'edit'){
332
  //don't add the required class if this is a file upload when editing
333
  }else
334
  $class .= " required";
335
  }
336
 
337
+ if($frm_settings->use_html and isset($field['default_value']) and !empty($field['default_value']) and !in_array($field['type'], array('select', 'radio', 'checkbox', 'hidden')))
338
  echo ' placeholder="'.$field['default_value'].'"';
339
 
340
  if(isset($field['clear_on_focus']) and $field['clear_on_focus']){
341
+ echo ' onfocus="frmClearDefault('."'". addslashes($field['default_value']) ."'". ', this)" onblur="frmReplaceDefault('."'".addslashes($field['default_value'])."'". ', this)"';
342
 
343
  if($field['value'] == $field['default_value'])
344
  echo ' style="font-style:italic;"';
345
  }
346
  }
347
 
348
+ $class = apply_filters('frm_field_classes', $class, $field);
349
  echo ' class="'.$class.'"';
350
  }
351
  }
classes/controllers/FrmFormsController.php CHANGED
@@ -6,20 +6,20 @@
6
  class FrmFormsController{
7
  function FrmFormsController(){
8
  add_action('admin_menu', array( &$this, 'menu' ));
9
- add_action('admin_head-toplevel_page_'.FRM_PLUGIN_NAME, array(&$this,'head'));
10
- add_action('admin_head-'.FRM_PLUGIN_NAME.'_page_'.FRM_PLUGIN_NAME.'-new', array(&$this,'head'));
11
- add_action('admin_head-'.FRM_PLUGIN_NAME.'_page_'.FRM_PLUGIN_NAME.'-templates', array(&$this,'head'));
12
  add_action('wp_ajax_frm_form_name_in_place_edit', array(&$this, 'edit_name') );
13
  add_action('wp_ajax_frm_form_desc_in_place_edit', array(&$this, 'edit_description') );
14
  add_action('wp_ajax_frm_delete_form_wo_fields',array(&$this, 'destroy_wo_fields'));
15
  add_filter('frm_submit_button', array(&$this, 'submit_button_label'));
16
- add_filter('media_buttons_context', array(&$this,'insert_form_button'));
17
  add_action('admin_footer', array(&$this, 'insert_form_popup'));
18
  }
19
 
20
  function menu(){
21
- add_submenu_page(FRM_PLUGIN_NAME, FRM_PLUGIN_TITLE .' | '. __('Forms', 'formidable'), __('Forms', 'formidable'), 'frm_view_forms', FRM_PLUGIN_NAME, array(&$this,'route'));
22
- add_submenu_page(FRM_PLUGIN_NAME, FRM_PLUGIN_TITLE .' | '. __('Create a Form', 'formidable'), __('Create a Form', 'formidable'), 'frm_edit_forms', FRM_PLUGIN_NAME.'-new', array(&$this,'new_form'));
23
  add_submenu_page(FRM_PLUGIN_NAME, FRM_PLUGIN_TITLE .' | '. __('Templates', 'formidable'), __('Templates', 'formidable'), 'frm_view_forms', FRM_PLUGIN_NAME.'-templates', array(&$this, 'template_list'));
24
  }
25
 
@@ -53,10 +53,11 @@ class FrmFormsController{
53
  $frm_field_selection = FrmFieldsHelper::field_selection();
54
  $values = FrmFormsHelper::setup_new_vars();
55
  $id = $frm_form->create( $values );
56
- require_once(FRM_VIEWS_PATH.'/frm-forms/new.php');
 
57
  }else{
58
- $all_templates = $frm_form->getAll('is_template=1',' ORDER BY name');
59
- require_once(FRM_VIEWS_PATH.'/frm-forms/new-selection.php');
60
  }
61
  }
62
 
@@ -66,11 +67,12 @@ class FrmFormsController{
66
  $id = FrmAppHelper::get_param('id');
67
 
68
  if( count($errors) > 0 ){
 
69
  $frm_field_selection = FrmFieldsHelper::field_selection();
70
  $record = $frm_form->getOne( $id );
71
- $fields = $frm_field->getAll("fi.form_id=$id", ' ORDER BY field_order');
72
- $values = FrmAppHelper::setup_edit_vars($record,'forms',$fields,true);
73
- require_once(FRM_VIEWS_PATH.'/frm-forms/new.php');
74
  }else{
75
  $record = $frm_form->update( $id, $_POST, true );
76
  $message = __('Form was Successfully Created', 'formidable');
@@ -148,13 +150,10 @@ class FrmFormsController{
148
  $plugin = FrmAppHelper::get_param('plugin');
149
  $controller = FrmAppHelper::get_param('controller');
150
  $key = (isset($_GET['form']) ? $_GET['form'] : (isset($_POST['form']) ? $_POST['form'] : ''));
151
- $form = $frm_form->getAll("form_key='$key'",'',' LIMIT 1');
152
- if (!$form) $form = $frm_form->getAll('','',' LIMIT 1');
153
- $form_options = stripslashes_deep(maybe_unserialize($form->options));
154
- $description = $title = true;
155
- $custom_style = (isset($form_options['custom_style'])) ? $form_options['custom_style'] : ($frm_settings->load_style != 'none');
156
 
157
- require_once(FRM_VIEWS_PATH.'/frm-entries/direct.php');
158
  }
159
 
160
  function destroy(){
@@ -188,7 +187,7 @@ class FrmFormsController{
188
  }
189
 
190
  function insert_form_button($content){
191
- $content .= '<a href="#TB_inline?width=450&height=550&inlineId=frm_insert_form" class="thickbox" title="' . __("Add Formidable Form", 'formidable') . '"><img src="'.FRM_IMAGES_URL.'/icon_16_bw.png" alt="' . __("Add Formidable Form", 'formidable') . '" /></a>';
192
  return $content;
193
  }
194
 
@@ -199,7 +198,7 @@ class FrmFormsController{
199
  global $frmpro_display;
200
  $displays = $frmpro_display->getAll();
201
  }
202
- require_once(FRM_VIEWS_PATH.'/frm-forms/insert_form_popup.php');
203
  }
204
  }
205
 
@@ -218,7 +217,7 @@ class FrmFormsController{
218
 
219
  if ($params['template']){
220
  $default_templates = $frm_form->getAll('default_template=1');
221
- $all_templates = $frm_form->getAll('is_template=1',' ORDER BY name');
222
  }
223
 
224
  $form_vars = $this->get_form_sort_vars($params, $where_clause);
@@ -238,11 +237,11 @@ class FrmFormsController{
238
  $search_str = $form_vars['search_str'];
239
 
240
  $record_count = $frm_app_helper->getRecordCount($form_vars['where_clause'], $frmdb->forms);
241
- $page_count = $frm_app_helper->getPageCount($frm_page_size,$form_vars['where_clause'], $frmdb->forms);
242
  $forms = $frm_app_helper->getPage($current_page, $frm_page_size, $form_vars['where_clause'], $form_vars['order_by'], $frmdb->forms);
243
  $page_last_record = $frm_app_helper->getLastRecordNum($record_count,$current_page,$frm_page_size);
244
  $page_first_record = $frm_app_helper->getFirstRecordNum($record_count,$current_page,$frm_page_size);
245
- require_once(FRM_VIEWS_PATH.'/frm-forms/list.php');
246
  }
247
 
248
  function get_form_sort_vars($params,$where_clause = ''){
@@ -296,50 +295,45 @@ class FrmFormsController{
296
  $sdir_str = 'desc';
297
  }
298
 
299
- return array('order_by' => $order_by,
300
- 'sort_str' => $sort_str,
301
- 'sdir_str' => $sdir_str,
302
- 'search_str' => $search_str,
303
- 'where_clause' => $where_clause,
304
- 'page_params' => $page_params);
305
  }
306
 
307
  function get_edit_vars($id, $errors = '', $message='', $create_link=false){
308
  global $frm_app_helper, $frm_entry, $frm_form, $frm_field, $frmpro_is_installed, $frm_ajax_url;
309
  $record = $frm_form->getOne( $id );
310
  $frm_field_selection = FrmFieldsHelper::field_selection();
311
- $fields = $frm_field->getAll("fi.form_id=$id", ' ORDER BY field_order');
312
- $values = FrmAppHelper::setup_edit_vars($record,'forms',$fields,true);
313
  if (isset($values['default_template']) && $values['default_template'])
314
  wp_die(__('That template cannot be edited', 'formidable'));
315
  else if($create_link)
316
- require_once(FRM_VIEWS_PATH.'/frm-forms/new.php');
317
  else
318
- require_once(FRM_VIEWS_PATH.'/frm-forms/edit.php');
319
  }
320
 
321
  function get_params(){
322
  $values = array();
323
- foreach (array('template' => 0,'id' => '','paged' => 1,'form' => '','search' => '','sort' => '','sdir' => '') as $var => $default)
324
  $values[$var] = FrmAppHelper::get_param($var, $default);
325
 
326
  return $values;
327
  }
328
 
329
- function add_default_templates($path, $default=true){
330
  global $frm_form, $frm_field;
331
  $templates = glob($path."/*.php");
332
 
333
  for($i = count($templates) - 1; $i >= 0; $i--){
334
- $filename = str_replace($path."/","",$templates[$i]);
335
- $filename = str_replace('.php','', $filename);
336
- $template_query = "form_key='{$filename}' and is_template='1'";
337
  if($default) $template_query .= " and default_template='1'";
338
  $form = $frm_form->getAll($template_query, '', ' LIMIT 1');
339
 
340
  $values = FrmFormsHelper::setup_new_vars();
341
  $values['form_key'] = $filename;
342
- $values['is_template'] = 1;
343
  $values['status'] = 'published';
344
  if($default) $values['default_template'] = 1;
345
 
6
  class FrmFormsController{
7
  function FrmFormsController(){
8
  add_action('admin_menu', array( &$this, 'menu' ));
9
+ add_action('admin_head-toplevel_page_'.FRM_PLUGIN_NAME, array(&$this, 'head'));
10
+ add_action('admin_head-'.FRM_PLUGIN_NAME.'_page_'.FRM_PLUGIN_NAME.'-new', array(&$this, 'head'));
11
+ add_action('admin_head-'.FRM_PLUGIN_NAME.'_page_'.FRM_PLUGIN_NAME.'-templates', array(&$this, 'head'));
12
  add_action('wp_ajax_frm_form_name_in_place_edit', array(&$this, 'edit_name') );
13
  add_action('wp_ajax_frm_form_desc_in_place_edit', array(&$this, 'edit_description') );
14
  add_action('wp_ajax_frm_delete_form_wo_fields',array(&$this, 'destroy_wo_fields'));
15
  add_filter('frm_submit_button', array(&$this, 'submit_button_label'));
16
+ add_filter('media_buttons_context', array(&$this, 'insert_form_button'));
17
  add_action('admin_footer', array(&$this, 'insert_form_popup'));
18
  }
19
 
20
  function menu(){
21
+ add_submenu_page(FRM_PLUGIN_NAME, FRM_PLUGIN_TITLE .' | '. __('Forms', 'formidable'), __('Forms', 'formidable'), 'frm_view_forms', FRM_PLUGIN_NAME, array(&$this, 'route'));
22
+ add_submenu_page(FRM_PLUGIN_NAME, FRM_PLUGIN_TITLE .' | '. __('Add New Form', 'formidable'), __('Add New Form', 'formidable'), 'frm_edit_forms', FRM_PLUGIN_NAME.'-new', array(&$this, 'new_form'));
23
  add_submenu_page(FRM_PLUGIN_NAME, FRM_PLUGIN_TITLE .' | '. __('Templates', 'formidable'), __('Templates', 'formidable'), 'frm_view_forms', FRM_PLUGIN_NAME.'-templates', array(&$this, 'template_list'));
24
  }
25
 
53
  $frm_field_selection = FrmFieldsHelper::field_selection();
54
  $values = FrmFormsHelper::setup_new_vars();
55
  $id = $frm_form->create( $values );
56
+ $values['id'] = $id;
57
+ require(FRM_VIEWS_PATH.'/frm-forms/new.php');
58
  }else{
59
+ $all_templates = $frm_form->getAll('is_template=1', ' ORDER BY name');
60
+ require(FRM_VIEWS_PATH.'/frm-forms/new-selection.php');
61
  }
62
  }
63
 
67
  $id = FrmAppHelper::get_param('id');
68
 
69
  if( count($errors) > 0 ){
70
+ $hide_preview = true;
71
  $frm_field_selection = FrmFieldsHelper::field_selection();
72
  $record = $frm_form->getOne( $id );
73
+ $fields = $frm_field->getAll("fi.form_id='$id'", ' ORDER BY field_order');
74
+ $values = FrmAppHelper::setup_edit_vars($record, 'forms', $fields, true);
75
+ require(FRM_VIEWS_PATH.'/frm-forms/new.php');
76
  }else{
77
  $record = $frm_form->update( $id, $_POST, true );
78
  $message = __('Form was Successfully Created', 'formidable');
150
  $plugin = FrmAppHelper::get_param('plugin');
151
  $controller = FrmAppHelper::get_param('controller');
152
  $key = (isset($_GET['form']) ? $_GET['form'] : (isset($_POST['form']) ? $_POST['form'] : ''));
153
+ $form = $frm_form->getAll("form_key='$key'", '', ' LIMIT 1');
154
+ if (!$form) $form = $frm_form->getAll('', '', ' LIMIT 1');
 
 
 
155
 
156
+ require(FRM_VIEWS_PATH.'/frm-entries/direct.php');
157
  }
158
 
159
  function destroy(){
187
  }
188
 
189
  function insert_form_button($content){
190
+ $content .= '<a href="#TB_inline?width=450&height=550&inlineId=frm_insert_form" class="thickbox" title="' . __("Add Formidable Form", 'formidable') . '"><img src="'.FRM_IMAGES_URL.'/form_16.png" alt="' . __("Add Formidable Form", 'formidable') . '" /></a>';
191
  return $content;
192
  }
193
 
198
  global $frmpro_display;
199
  $displays = $frmpro_display->getAll();
200
  }
201
+ require(FRM_VIEWS_PATH.'/frm-forms/insert_form_popup.php');
202
  }
203
  }
204
 
217
 
218
  if ($params['template']){
219
  $default_templates = $frm_form->getAll('default_template=1');
220
+ $all_templates = $frm_form->getAll('is_template=1', ' ORDER BY name');
221
  }
222
 
223
  $form_vars = $this->get_form_sort_vars($params, $where_clause);
237
  $search_str = $form_vars['search_str'];
238
 
239
  $record_count = $frm_app_helper->getRecordCount($form_vars['where_clause'], $frmdb->forms);
240
+ $page_count = $frm_app_helper->getPageCount($frm_page_size, $record_count, $frmdb->forms);
241
  $forms = $frm_app_helper->getPage($current_page, $frm_page_size, $form_vars['where_clause'], $form_vars['order_by'], $frmdb->forms);
242
  $page_last_record = $frm_app_helper->getLastRecordNum($record_count,$current_page,$frm_page_size);
243
  $page_first_record = $frm_app_helper->getFirstRecordNum($record_count,$current_page,$frm_page_size);
244
+ require(FRM_VIEWS_PATH.'/frm-forms/list.php');
245
  }
246
 
247
  function get_form_sort_vars($params,$where_clause = ''){
295
  $sdir_str = 'desc';
296
  }
297
 
298
+ return compact('order_by', 'sort_str', 'sdir_str', 'search_str', 'where_clause', 'page_params');
 
 
 
 
 
299
  }
300
 
301
  function get_edit_vars($id, $errors = '', $message='', $create_link=false){
302
  global $frm_app_helper, $frm_entry, $frm_form, $frm_field, $frmpro_is_installed, $frm_ajax_url;
303
  $record = $frm_form->getOne( $id );
304
  $frm_field_selection = FrmFieldsHelper::field_selection();
305
+ $fields = $frm_field->getAll("fi.form_id='$id'", ' ORDER BY field_order');
306
+ $values = FrmAppHelper::setup_edit_vars($record, 'forms', $fields, true);
307
  if (isset($values['default_template']) && $values['default_template'])
308
  wp_die(__('That template cannot be edited', 'formidable'));
309
  else if($create_link)
310
+ require(FRM_VIEWS_PATH.'/frm-forms/new.php');
311
  else
312
+ require(FRM_VIEWS_PATH.'/frm-forms/edit.php');
313
  }
314
 
315
  function get_params(){
316
  $values = array();
317
+ foreach (array('template' => 0, 'id' => '', 'paged' => 1, 'form' => '', 'search' => '', 'sort' => '', 'sdir' => '') as $var => $default)
318
  $values[$var] = FrmAppHelper::get_param($var, $default);
319
 
320
  return $values;
321
  }
322
 
323
+ function add_default_templates($path, $default=true, $template=true){
324
  global $frm_form, $frm_field;
325
  $templates = glob($path."/*.php");
326
 
327
  for($i = count($templates) - 1; $i >= 0; $i--){
328
+ $filename = str_replace('.php', '', str_replace($path.'/', '', $templates[$i]));
329
+ $template_query = "form_key='{$filename}'";
330
+ if($template) $template_query .= " and is_template='1'";
331
  if($default) $template_query .= " and default_template='1'";
332
  $form = $frm_form->getAll($template_query, '', ' LIMIT 1');
333
 
334
  $values = FrmFormsHelper::setup_new_vars();
335
  $values['form_key'] = $filename;
336
+ $values['is_template'] = $template;
337
  $values['status'] = 'published';
338
  if($default) $values['default_template'] = 1;
339
 
classes/controllers/FrmSettingsController.php CHANGED
@@ -7,19 +7,19 @@ class FrmSettingsController{
7
  function FrmSettingsController(){
8
  add_action('admin_menu', array( &$this, 'menu' ), 26);
9
  add_action('admin_menu', array( &$this, 'pro_menu' ), 19);
10
- //add_action('admin_head-'.FRM_PLUGIN_NAME.'_page_'.FRM_PLUGIN_NAME.'-settings', array($this,'head'));
11
  }
12
 
13
  function menu(){
14
- add_submenu_page(FRM_PLUGIN_NAME, FRM_PLUGIN_TITLE .' | '. __('Settings', 'formidable'), __('Settings', 'formidable'), 'frm_change_settings', FRM_PLUGIN_NAME.'-settings', array(&$this,'route'));
15
  }
16
 
17
  function pro_menu(){
18
  global $frm_update;
19
- if (IS_WPMU and !is_site_admin() and get_site_option($frm_update->pro_wpmu_store))
20
  return;
21
 
22
- add_submenu_page(FRM_PLUGIN_NAME, FRM_PLUGIN_TITLE .' | '. FRM_PLUGIN_TITLE . ' Pro', FRM_PLUGIN_TITLE . ' Pro', 'administrator', FRM_PLUGIN_NAME.'-pro-settings', array($frm_update,'pro_cred_form'));
23
  }
24
 
25
  function display_form(){
@@ -29,7 +29,7 @@ class FrmSettingsController{
29
  $uploads = wp_upload_dir();
30
  $target_path = $uploads['basedir'] . "/formidable/css";
31
 
32
- require_once(FRM_VIEWS_PATH . '/frm-settings/form.php');
33
  }
34
 
35
  function process_form(){
@@ -44,7 +44,7 @@ class FrmSettingsController{
44
  $message = __('Settings Saved', 'formidable');
45
  }
46
  $frm_roles = FrmAppHelper::frm_capabilities();
47
- require_once(FRM_VIEWS_PATH . '/frm-settings/form.php');
48
  }
49
 
50
  function route(){
7
  function FrmSettingsController(){
8
  add_action('admin_menu', array( &$this, 'menu' ), 26);
9
  add_action('admin_menu', array( &$this, 'pro_menu' ), 19);
10
+ //add_action('admin_head-'.FRM_PLUGIN_NAME.'_page_'.FRM_PLUGIN_NAME.'-settings', array(&$this, 'head'));
11
  }
12
 
13
  function menu(){
14
+ add_submenu_page(FRM_PLUGIN_NAME, FRM_PLUGIN_TITLE .' | '. __('Settings', 'formidable'), __('Settings', 'formidable'), 'frm_change_settings', FRM_PLUGIN_NAME.'-settings', array(&$this, 'route'));
15
  }
16
 
17
  function pro_menu(){
18
  global $frm_update;
19
+ if (IS_WPMU and !FrmAppHelper::is_super_admin() and get_site_option($frm_update->pro_wpmu_store))
20
  return;
21
 
22
+ add_submenu_page(FRM_PLUGIN_NAME, FRM_PLUGIN_TITLE .' | '. FRM_PLUGIN_TITLE . ' Pro', FRM_PLUGIN_TITLE . ' Pro', 'administrator', FRM_PLUGIN_NAME.'-pro-settings', array($frm_update, 'pro_cred_form'));
23
  }
24
 
25
  function display_form(){
29
  $uploads = wp_upload_dir();
30
  $target_path = $uploads['basedir'] . "/formidable/css";
31
 
32
+ require(FRM_VIEWS_PATH . '/frm-settings/form.php');
33
  }
34
 
35
  function process_form(){
44
  $message = __('Settings Saved', 'formidable');
45
  }
46
  $frm_roles = FrmAppHelper::frm_capabilities();
47
+ require(FRM_VIEWS_PATH . '/frm-settings/form.php');
48
  }
49
 
50
  function route(){
classes/controllers/FrmStatisticsController.php CHANGED
@@ -11,11 +11,11 @@ class FrmStatisticsController{
11
  function menu(){
12
  global $frmpro_is_installed;
13
  if(!$frmpro_is_installed)
14
- add_submenu_page(FRM_PLUGIN_TITLE, FRM_PLUGIN_TITLE .' | Statistics', 'Statistics', 'administrator', FRM_PLUGIN_TITLE.'-statistics',array($this,''));
15
  }
16
 
17
  function list_entries(){
18
- require_once(FRM_VIEWS_PATH . '/frm-statistics/list.php');
19
  }
20
 
21
  }
11
  function menu(){
12
  global $frmpro_is_installed;
13
  if(!$frmpro_is_installed)
14
+ add_submenu_page(FRM_PLUGIN_TITLE, FRM_PLUGIN_TITLE .' | Statistics', 'Statistics', 'administrator', FRM_PLUGIN_TITLE.'-statistics', array(&$this, ''));
15
  }
16
 
17
  function list_entries(){
18
+ require(FRM_VIEWS_PATH . '/frm-statistics/list.php');
19
  }
20
 
21
  }
classes/helpers/FrmAppHelper.php CHANGED
@@ -18,7 +18,7 @@ class FrmAppHelper{
18
  <select name="<?php echo $field_name; ?>" id="<?php echo $field_name; ?>" class="frm-dropdown frm-pages-dropdown">
19
  <option value=""></option>
20
  <?php foreach($pages as $page){ ?>
21
- <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 ($truncate)? substr($page->post_title, 0, $truncate) : $page->post_title; ?> </option>
22
  <?php } ?>
23
  </select>
24
  <?php
@@ -42,36 +42,90 @@ class FrmAppHelper{
42
  global $frmpro_is_installed;
43
  $cap = array(
44
  'frm_view_forms' => __('View Forms and Templates', 'formidable'),
45
- 'frm_edit_forms' => __('Create/Edit Forms and Templates', 'formidable'),
46
  'frm_delete_forms' => __('Delete Forms and Templates', 'formidable'),
47
  'frm_change_settings' => __('Access this Settings Page', 'formidable')
48
  );
49
  if($frmpro_is_installed){
50
  $cap['frm_view_entries'] = __('View Entries from Admin Area', 'formidable');
51
- $cap['frm_create_entries'] = __('Create Entries from Admin Area', 'formidable');
52
  $cap['frm_edit_entries'] = __('Edit Entries from Admin Area', 'formidable');
53
  $cap['frm_delete_entries'] = __('Delete Entries from Admin Area', 'formidable');
54
  $cap['frm_view_reports'] = __('View Reports', 'formidable');
55
- $cap['frm_edit_displays'] = __('Create/Edit Custom Displays', 'formidable');
56
  }
57
  return $cap;
58
  }
59
 
60
- function user_has_permission($needed_role){
61
- if ($needed_role == '' or
62
- ($needed_role == 'administrator' and current_user_can('administrator')) or
63
- ($needed_role == 'subscriber' and current_user_can('level_0')) or
64
- ($needed_role == 'contributer' and current_user_can('level_1')) or
65
- ($needed_role == 'author' and (current_user_can('author') or current_user_can('editor') or current_user_can('administrator'))) or
66
- ($needed_role == 'editor' and (current_user_can('editor') or current_user_can('administrator'))) )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
67
  return true;
68
  else
69
  return false;
70
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
 
72
- function value_is_checked_with_array($field_name, $index, $field_value){
73
- if( ( $_POST['action'] == 'process_form' and isset( $_POST[ $field_name ][ $index ] ) ) or ( $_POST['action'] != 'process_form' and isset($field_value) ) )
74
- echo ' checked="checked"';
75
  }
76
 
77
  function get_file_contents($filename){
@@ -85,13 +139,13 @@ class FrmAppHelper{
85
  return false;
86
  }
87
 
88
- function get_unique_key($name='', $table_name, $column, $id = 0,$num_chars = 6){
89
  global $wpdb;
90
 
91
  if ($name == ''){
92
- $max_slug_value = pow(36,$num_chars);
93
  $min_slug_value = 37; // we want to have at least 2 characters in the slug
94
- $key = base_convert( rand($min_slug_value,$max_slug_value), 10, 36 );
95
  }else{
96
  if(function_exists('sanitize_key'))
97
  $key = sanitize_key($name);
@@ -99,7 +153,7 @@ class FrmAppHelper{
99
  $key = sanitize_title_with_dashes($name);
100
  }
101
 
102
- if (is_numeric($key) or in_array($key, array('id','key','created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd')))
103
  $key = $key .'a';
104
 
105
  $query = "SELECT $column FROM $table_name WHERE $column = %s AND ID != %d LIMIT 1";
@@ -120,7 +174,7 @@ class FrmAppHelper{
120
  //Editing a Form or Entry
121
  function setup_edit_vars($record, $table, $fields='', $default=false){
122
  if(!$record) return false;
123
- global $frm_entry_meta, $frm_form, $frm_settings;
124
  $values = array();
125
 
126
  $values['id'] = $record->id;
@@ -132,47 +186,58 @@ class FrmAppHelper{
132
 
133
  if ($fields){
134
  foreach($fields as $field){
135
- $field_options = stripslashes_deep(unserialize($field->field_options));
136
-
137
- if ($default)
138
  $meta_value = $field->default_value;
139
- else{
140
- if($record->post_id and class_exists('FrmProEntryMetaHelper') and isset($field_options['post_field']) and $field_options['post_field']){
141
- $meta_value = FrmProEntryMetaHelper::get_post_value($record->post_id, $field_options['post_field'], $field_options['custom_field'], array('truncate' => false, 'type' => $field->type));
142
- }else if(isset($record->metas))
143
  $meta_value = isset($record->metas[$field->id]) ? $record->metas[$field->id] : false;
144
- else
145
  $meta_value = $frm_entry_meta->get_entry_meta_by_field($record->id, $field->id, true);
 
146
  }
147
 
148
  $field_type = isset($_POST['field_options']['type_'.$field->id]) ? $_POST['field_options']['type_'.$field->id] : $field->type;
149
  $new_value = (isset($_POST['item_meta'][$field->id])) ? $_POST['item_meta'][$field->id] : $meta_value;
150
  $new_value = stripslashes_deep(maybe_unserialize($new_value));
151
 
152
- $field_array = array('id' => $field->id,
153
- 'value' => str_replace('"', '&quot;', $new_value),
154
- 'default_value' => str_replace('"', '&quot;', stripslashes($field->default_value)),
155
- 'name' => stripslashes($field->name),
156
- 'description' => stripslashes($field->description),
157
- 'type' => apply_filters('frm_field_type',$field_type, $field),
158
- 'options' => str_replace('"', '&quot;', stripslashes_deep(maybe_unserialize($field->options))),
159
- 'required' => $field->required,
160
- 'field_key' => $field->field_key,
161
- 'field_order' => $field->field_order,
162
- 'form_id' => $field->form_id);
 
 
163
 
164
  foreach (array('size' => '', 'max' => '', 'label' => 'top', 'invalid' => '', 'required_indicator' => '*', 'blank' => '', 'clear_on_focus' => 0, 'custom_html' => '', 'default_blank' => 0) as $opt => $default_opt){
165
- $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);
166
- if($opt == 'blank' and $field_array[$opt] == '')
167
- $field_array[$opt] = $field_array['name'] . ' ' . __('cannot be blank', 'formidable');
168
- else if($opt == 'invalid' and $field_array[$opt] == '')
169
- $field_array[$opt] = $field_array['name'] . ' ' . __('is an invalid format', 'formidable');
 
 
 
 
170
  }
171
 
172
  if ($field_array['custom_html'] == '')
173
  $field_array['custom_html'] = FrmFieldsHelper::get_default_html($field_type);
174
-
175
- $values['fields'][] = apply_filters('frm_setup_edit_fields_vars', stripslashes_deep($field_array), $field, $values['id']);
 
 
 
 
176
  }
177
  }
178
 
@@ -182,10 +247,10 @@ class FrmAppHelper{
182
  $form = $frm_form->getOne( $record->id );
183
 
184
  if ($form){
 
185
  $values['form_name'] = (isset($record->form_id))?($form->name):('');
186
- $options = stripslashes_deep(unserialize($form->options));
187
- if (is_array($options)){
188
- foreach ($options as $opt => $value)
189
  $values[$opt] = FrmAppHelper::get_param($opt, $value);
190
  }
191
  }
@@ -223,6 +288,101 @@ class FrmAppHelper{
223
  return $values;
224
  }
225
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
226
  function frm_get_main_message( $message = ''){
227
  global $frmpro_is_installed;
228
  include_once(ABSPATH."/wp-includes/class-IXR.php");
@@ -237,6 +397,7 @@ class FrmAppHelper{
237
  }
238
 
239
  function truncate($str, $length, $minword = 3, $continue = '...'){
 
240
  $sub = '';
241
  $len = 0;
242
 
@@ -275,7 +436,10 @@ class FrmAppHelper{
275
  }
276
 
277
  function getPageCount($p_size, $where="", $table_name){
278
- return ceil((int)$this->getRecordCount($where, $table_name) / (int)$p_size);
 
 
 
279
  }
280
 
281
  function getPage($current_p,$p_size, $where = "", $order_by = '', $table_name){
@@ -287,6 +451,63 @@ class FrmAppHelper{
287
  return $results;
288
  }
289
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
290
  }
291
 
292
  ?>
18
  <select name="<?php echo $field_name; ?>" id="<?php echo $field_name; ?>" class="frm-dropdown frm-pages-dropdown">
19
  <option value=""></option>
20
  <?php foreach($pages as $page){ ?>
21
+ <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 ($truncate)? FrmAppHelper::truncate($page->post_title, $truncate) : $page->post_title; ?> </option>
22
  <?php } ?>
23
  </select>
24
  <?php
42
  global $frmpro_is_installed;
43
  $cap = array(
44
  'frm_view_forms' => __('View Forms and Templates', 'formidable'),
45
+ 'frm_edit_forms' => __('Add/Edit Forms and Templates', 'formidable'),
46
  'frm_delete_forms' => __('Delete Forms and Templates', 'formidable'),
47
  'frm_change_settings' => __('Access this Settings Page', 'formidable')
48
  );
49
  if($frmpro_is_installed){
50
  $cap['frm_view_entries'] = __('View Entries from Admin Area', 'formidable');
51
+ $cap['frm_create_entries'] = __('Add Entries from Admin Area', 'formidable');
52
  $cap['frm_edit_entries'] = __('Edit Entries from Admin Area', 'formidable');
53
  $cap['frm_delete_entries'] = __('Delete Entries from Admin Area', 'formidable');
54
  $cap['frm_view_reports'] = __('View Reports', 'formidable');
55
+ $cap['frm_edit_displays'] = __('Add/Edit Custom Displays', 'formidable');
56
  }
57
  return $cap;
58
  }
59
 
60
+ function user_has_permission($needed_role){
61
+ if($needed_role == '' or current_user_can($needed_role))
62
+ return true;
63
+
64
+ $roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' );
65
+ foreach ($roles as $role){
66
+ if (current_user_can($role))
67
+ return true;
68
+ if ($role == $needed_role)
69
+ break;
70
+ }
71
+ return false;
72
+ }
73
+
74
+ function is_super_admin($user_id=false){
75
+ if(function_exists('is_super_admin'))
76
+ return is_super_admin($user_id);
77
+ else
78
+ return is_site_admin($user_id);
79
+ }
80
+
81
+ function checked($values, $current){
82
+ if(FrmAppHelper::check_selected($values, $current))
83
+ echo ' checked="checked"';
84
+ }
85
+
86
+ function check_selected($values, $current){
87
+ if(is_array($values))
88
+ $values = array_map('trim', $values);
89
+ else
90
+ $values = trim($values);
91
+ $current = trim($current);
92
+
93
+ /*if(is_array($values))
94
+ $values = array_map('htmlentities', $values);
95
+ else
96
+ $values = htmlentities($values);
97
+
98
+ $values = preg_replace("/&#?[a-z0-9]{2,8};/i", "", $values);
99
+ $current = preg_replace("/&#?[a-z0-9]{2,8};/i", "", $current);
100
+ */
101
+
102
+
103
+ if((is_array($values) && in_array($current, $values)) or (!is_array($values) and $values == $current))
104
  return true;
105
  else
106
  return false;
107
  }
108
+
109
+ function esc_textarea( $text ) {
110
+ $safe_text = str_replace('&quot;', '"', $text);
111
+ $safe_text = htmlspecialchars( $safe_text, ENT_NOQUOTES );
112
+ return apply_filters( 'esc_textarea', $safe_text, $text );
113
+ }
114
+
115
+ function script_version($handle, $list='scripts'){
116
+ global $wp_scripts;
117
+ if(!$wp_scripts)
118
+ return false;
119
+
120
+ $ver = 0;
121
+
122
+ if ( isset($wp_scripts->registered[$handle]) )
123
+ $query = $wp_scripts->registered[$handle];
124
+
125
+ if ( is_object( $query ) )
126
+ $ver = $query->ver;
127
 
128
+ return $ver;
 
 
129
  }
130
 
131
  function get_file_contents($filename){
139
  return false;
140
  }
141
 
142
+ function get_unique_key($name='', $table_name, $column, $id = 0, $num_chars = 6){
143
  global $wpdb;
144
 
145
  if ($name == ''){
146
+ $max_slug_value = pow(36, $num_chars);
147
  $min_slug_value = 37; // we want to have at least 2 characters in the slug
148
+ $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 );
149
  }else{
150
  if(function_exists('sanitize_key'))
151
  $key = sanitize_key($name);
153
  $key = sanitize_title_with_dashes($name);
154
  }
155
 
156
+ if (is_numeric($key) or in_array($key, array('id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd')))
157
  $key = $key .'a';
158
 
159
  $query = "SELECT $column FROM $table_name WHERE $column = %s AND ID != %d LIMIT 1";
174
  //Editing a Form or Entry
175
  function setup_edit_vars($record, $table, $fields='', $default=false){
176
  if(!$record) return false;
177
+ global $frm_entry_meta, $frm_form, $frm_settings, $frm_sidebar_width;
178
  $values = array();
179
 
180
  $values['id'] = $record->id;
186
 
187
  if ($fields){
188
  foreach($fields as $field){
189
+ $field->field_options = stripslashes_deep(maybe_unserialize($field->field_options));
190
+
191
+ if ($default){
192
  $meta_value = $field->default_value;
193
+ }else{
194
+ if($record->post_id and class_exists('FrmProEntryMetaHelper') and isset($field->field_options['post_field']) and $field->field_options['post_field']){
195
+ $meta_value = FrmProEntryMetaHelper::get_post_value($record->post_id, $field->field_options['post_field'], $field->field_options['custom_field'], array('truncate' => false, 'type' => $field->type, 'form_id' => $field->form_id, 'field' => $field));
196
+ }else if(isset($record->metas)){
197
  $meta_value = isset($record->metas[$field->id]) ? $record->metas[$field->id] : false;
198
+ }else{
199
  $meta_value = $frm_entry_meta->get_entry_meta_by_field($record->id, $field->id, true);
200
+ }
201
  }
202
 
203
  $field_type = isset($_POST['field_options']['type_'.$field->id]) ? $_POST['field_options']['type_'.$field->id] : $field->type;
204
  $new_value = (isset($_POST['item_meta'][$field->id])) ? $_POST['item_meta'][$field->id] : $meta_value;
205
  $new_value = stripslashes_deep(maybe_unserialize($new_value));
206
 
207
+ $field_array = array(
208
+ 'id' => $field->id,
209
+ 'value' => str_replace('"', '&quot;', $new_value),
210
+ 'default_value' => str_replace('"', '&quot;', stripslashes_deep(maybe_unserialize($field->default_value))),
211
+ 'name' => stripslashes($field->name),
212
+ 'description' => stripslashes($field->description),
213
+ 'type' => apply_filters('frm_field_type', $field_type, $field, $new_value),
214
+ 'options' => str_replace('"', '&quot;', stripslashes_deep(maybe_unserialize($field->options))),
215
+ 'required' => $field->required,
216
+ 'field_key' => $field->field_key,
217
+ 'field_order' => $field->field_order,
218
+ 'form_id' => $field->form_id
219
+ );
220
 
221
  foreach (array('size' => '', 'max' => '', 'label' => 'top', 'invalid' => '', 'required_indicator' => '*', 'blank' => '', 'clear_on_focus' => 0, 'custom_html' => '', 'default_blank' => 0) as $opt => $default_opt){
222
+ $field_array[$opt] = ($_POST and isset($_POST['field_options'][$opt.'_'.$field->id]) ) ? $_POST['field_options'][$opt.'_'.$field->id] : (isset($field->field_options[$opt]) ? $field->field_options[$opt] : $default_opt);
223
+ if($opt == 'blank' and $field_array[$opt] == ''){
224
+ $field_array[$opt] = __('This field cannot be blank', 'formidable');
225
+ }else if($opt == 'invalid' and $field_array[$opt] == ''){
226
+ if($field_type == 'captcha')
227
+ $field_array[$opt] = $frm_settings->re_msg;
228
+ else
229
+ $field_array[$opt] = $field_array['name'] . ' ' . __('is invalid', 'formidable');
230
+ }
231
  }
232
 
233
  if ($field_array['custom_html'] == '')
234
  $field_array['custom_html'] = FrmFieldsHelper::get_default_html($field_type);
235
+
236
+ if ($field_array['size'] == '')
237
+ $field_array['size'] = $frm_sidebar_width;
238
+
239
+ $values['fields'][] = apply_filters('frm_setup_edit_fields_vars', stripslashes_deep($field_array), $field, $values['id']);
240
+ unset($field);
241
  }
242
  }
243
 
247
  $form = $frm_form->getOne( $record->id );
248
 
249
  if ($form){
250
+ $form->options = maybe_unserialize($form->options);
251
  $values['form_name'] = (isset($record->form_id))?($form->name):('');
252
+ if (is_array($form->options)){
253
+ foreach ($form->options as $opt => $value)
 
254
  $values[$opt] = FrmAppHelper::get_param($opt, $value);
255
  }
256
  }
288
  return $values;
289
  }
290
 
291
+ function get_us_states(){
292
+ return apply_filters('frm_us_states', array(
293
+ 'AL' => 'Alabama', 'AK' => 'Alaska', 'AS' => 'Arkansas', 'AZ' => 'Arizona',
294
+ 'CA' => 'California', 'CO' => 'Colorado', 'CT' => 'Connecticut', 'DE' => 'Delaware',
295
+ 'FL' => 'Florida', 'GA' => 'Georgia', 'HI' => 'Hawaii', 'ID' => 'Idaho',
296
+ 'IL' => 'Illinois', 'IN' => 'Indiana', 'IA' => 'Iowa', 'KS' => 'Kansas',
297
+ 'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine','MD' => 'Maryland',
298
+ 'MA' => 'Massachusetts', 'MI' => 'Michigan', 'MN' => 'Minnesota', 'MS' => 'Mississippi',
299
+ 'MO' => 'Missouri', 'MT' => 'Montana', 'NE' => 'Nebraska', 'NV' => 'Nevada',
300
+ 'NH' => 'New Hampshire', 'NJ' => 'New Jersey', 'NM' => 'New Mexico', 'NY' => 'New York',
301
+ 'NC' => 'North Carolina', 'ND' => 'North Dakota', 'OH' => 'Ohio', 'OK' => 'Oklahoma',
302
+ 'OR' => 'Oregon', 'PA' => 'Pennsylvania', 'RI' => 'Rhode Island', 'SC' => 'South Carolina',
303
+ 'SD' => 'South Dakota', 'TN' => 'Tennessee', 'TX' => 'Texas', 'UT' => 'Utah',
304
+ 'VT' => 'Vermont', 'VA' => 'Virginia', 'WA' => 'Washington', 'WV' => 'West Virginia',
305
+ 'WI' => 'Wisconsin', 'WY' => 'Wyoming'
306
+ ));
307
+ }
308
+
309
+ function get_countries(){
310
+ return apply_filters('frm_countries', array(
311
+ __('Afghanistan', 'formidable'), __('Albania', 'formidable'), __('Algeria', 'formidable'),
312
+ __('American Samoa', 'formidable'), __('Andorra', 'formidable'), __('Angola', 'formidable'),
313
+ __('Anguilla', 'formidable'), __('Antarctica', 'formidable'), __('Antigua and Barbuda', 'formidable'),
314
+ __('Argentina', 'formidable'), __('Armenia', 'formidable'), __('Aruba', 'formidable'),
315
+ __('Australia', 'formidable'), __('Austria', 'formidable'), __('Azerbaijan', 'formidable'),
316
+ __('Bahamas', 'formidable'), __('Bahrain', 'formidable'), __('Bangladesh', 'formidable'),
317
+ __('Barbados', 'formidable'), __('Belarus', 'formidable'), __('Belgium', 'formidable'),
318
+ __('Belize', 'formidable'), __('Benin', 'formidable'), __('Bermuda', 'formidable'),
319
+ __('Bhutan', 'formidable'), __('Bolivia', 'formidable'), __('Bosnia and Herzegovina', 'formidable'),
320
+ __('Botswana', 'formidable'), __('Brazil', 'formidable'), __('Brunei', 'formidable'),
321
+ __('Bulgaria', 'formidable'), __('Burkina Faso', 'formidable'), __('Burundi', 'formidable'),
322
+ __('Cambodia', 'formidable'), __('Cameroon', 'formidable'), __('Canada', 'formidable'),
323
+ __('Cape Verde', 'formidable'), __('Cayman Islands', 'formidable'), __('Central African Republic', 'formidable'),
324
+ __('Chad', 'formidable'), __('Chile', 'formidable'), __('China', 'formidable'),
325
+ __('Colombia', 'formidable'), __('Comoros', 'formidable'), __('Congo', 'formidable'),
326
+ __('Costa Rica', 'formidable'), __('C&ocirc;te d\'Ivoire', 'formidable'), __('Croatia', 'formidable'),
327
+ __('Cuba', 'formidable'), __('Cyprus', 'formidable'), __('Czech Republic', 'formidable'),
328
+ __('Denmark', 'formidable'), __('Djibouti', 'formidable'), __('Dominica', 'formidable'),
329
+ __('Dominican Republic', 'formidable'), __('East Timor', 'formidable'), __('Ecuador', 'formidable'),
330
+ __('Egypt', 'formidable'), __('El Salvador', 'formidable'), __('Equatorial Guinea', 'formidable'),
331
+ __('Eritrea', 'formidable'), __('Estonia', 'formidable'), __('Ethiopia', 'formidable'),
332
+ __('Fiji', 'formidable'), __('Finland', 'formidable'), __('France', 'formidable'),
333
+ __('French Guiana', 'formidable'), __('French Polynesia', 'formidable'), __('Gabon', 'formidable'),
334
+ __('Gambia', 'formidable'), __('Georgia', 'formidable'), __('Germany', 'formidable'),
335
+ __('Ghana', 'formidable'), __('Gibraltar', 'formidable'), __('Greece', 'formidable'),
336
+ __('Greenland', 'formidable'), __('Grenada', 'formidable'), __('Guam', 'formidable'),
337
+ __('Guatemala', 'formidable'), __('Guinea', 'formidable'), __('Guinea-Bissau', 'formidable'),
338
+ __('Guyana', 'formidable'), __('Haiti', 'formidable'), __('Honduras', 'formidable'),
339
+ __('Hong Kong', 'formidable'), __('Hungary', 'formidable'), __('Iceland', 'formidable'),
340
+ __('India', 'formidable'), __('Indonesia', 'formidable'), __('Iran', 'formidable'),
341
+ __('Iraq', 'formidable'), __('Ireland', 'formidable'), __('Israel', 'formidable'),
342
+ __('Italy', 'formidable'), __('Jamaica', 'formidable'), __('Japan', 'formidable'),
343
+ __('Jordan', 'formidable'), __('Kazakhstan', 'formidable'), __('Kenya', 'formidable'),
344
+ __('Kiribati', 'formidable'), __('North Korea', 'formidable'), __('South Korea', 'formidable'),
345
+ __('Kuwait', 'formidable'), __('Kyrgyzstan', 'formidable'), __('Laos', 'formidable'),
346
+ __('Latvia', 'formidable'), __('Lebanon', 'formidable'), __('Lesotho', 'formidable'),
347
+ __('Liberia', 'formidable'), __('Libya', 'formidable'), __('Liechtenstein', 'formidable'),
348
+ __('Lithuania', 'formidable'), __('Luxembourg', 'formidable'), __('Macedonia', 'formidable'),
349
+ __('Madagascar', 'formidable'), __('Malawi', 'formidable'), __('Malaysia', 'formidable'),
350
+ __('Maldives', 'formidable'), __('Mali', 'formidable'), __('Malta', 'formidable'),
351
+ __('Marshall Islands', 'formidable'), __('Mauritania', 'formidable'), __('Mauritius', 'formidable'),
352
+ __('Mexico', 'formidable'), __('Micronesia', 'formidable'), __('Moldova', 'formidable'),
353
+ __('Monaco', 'formidable'), __('Mongolia', 'formidable'), __('Montenegro', 'formidable'),
354
+ __('Montserrat', 'formidable'), __('Morocco', 'formidable'), __('Mozambique', 'formidable'),
355
+ __('Myanmar', 'formidable'), __('Namibia', 'formidable'), __('Nauru', 'formidable'),
356
+ __('Nepal', 'formidable'), __('Netherlands', 'formidable'), __('New Zealand', 'formidable'),
357
+ __('Nicaragua', 'formidable'), __('Niger', 'formidable'), __('Nigeria', 'formidable'),
358
+ __('Norway', 'formidable'), __('Northern Mariana Islands', 'formidable'), __('Oman', 'formidable'),
359
+ __('Pakistan', 'formidable'), __('Palau', 'formidable'), __('Palestine', 'formidable'),
360
+ __('Panama', 'formidable'), __('Papua New Guinea', 'formidable'), __('Paraguay', 'formidable'),
361
+ __('Peru', 'formidable'), __('Philippines', 'formidable'), __('Poland', 'formidable'),
362
+ __('Portugal', 'formidable'), __('Puerto Rico', 'formidable'), __('Qatar', 'formidable'),
363
+ __('Romania', 'formidable'), __('Russia', 'formidable'), __('Rwanda', 'formidable'),
364
+ __('Saint Kitts and Nevis', 'formidable'), __('Saint Lucia', 'formidable'),
365
+ __('Saint Vincent and the Grenadines', 'formidable'), __('Samoa', 'formidable'),
366
+ __('San Marino', 'formidable'), __('Sao Tome and Principe', 'formidable'), __('Saudi Arabia', 'formidable'),
367
+ __('Senegal', 'formidable'), __('Serbia and Montenegro', 'formidable'), __('Seychelles', 'formidable'),
368
+ __('Sierra Leone', 'formidable'), __('Singapore', 'formidable'), __('Slovakia', 'formidable'),
369
+ __('Slovenia', 'formidable'), __('Solomon Islands', 'formidable'), __('Somalia', 'formidable'),
370
+ __('South Africa', 'formidable'), __('Spain', 'formidable'), __('Sri Lanka', 'formidable'),
371
+ __('Sudan', 'formidable'), __('Suriname', 'formidable'), __('Swaziland', 'formidable'),
372
+ __('Sweden', 'formidable'), __('Switzerland', 'formidable'), __('Syria', 'formidable'),
373
+ __('Taiwan', 'formidable'), __('Tajikistan', 'formidable'), __('Tanzania', 'formidable'),
374
+ __('Thailand', 'formidable'), __('Togo', 'formidable'), __('Tonga', 'formidable'),
375
+ __('Trinidad and Tobago', 'formidable'), __('Tunisia', 'formidable'), __('Turkey', 'formidable'),
376
+ __('Turkmenistan', 'formidable'), __('Tuvalu', 'formidable'), __('Uganda', 'formidable'),
377
+ __('Ukraine', 'formidable'), __('United Arab Emirates', 'formidable'), __('United Kingdom', 'formidable'),
378
+ __('United States', 'formidable'), __('Uruguay', 'formidable'), __('Uzbekistan', 'formidable'),
379
+ __('Vanuatu', 'formidable'), __('Vatican City', 'formidable'), __('Venezuela', 'formidable'),
380
+ __('Vietnam', 'formidable'), __('Virgin Islands, British', 'formidable'),
381
+ __('Virgin Islands, U.S.', 'formidable'), __('Yemen', 'formidable'), __('Zambia', 'formidable'),
382
+ __('Zimbabwe', 'formidable')
383
+ ));
384
+ }
385
+
386
  function frm_get_main_message( $message = ''){
387
  global $frmpro_is_installed;
388
  include_once(ABSPATH."/wp-includes/class-IXR.php");
397
  }
398
 
399
  function truncate($str, $length, $minword = 3, $continue = '...'){
400
+ $str = stripslashes(esc_attr(strip_tags($str)));
401
  $sub = '';
402
  $len = 0;
403
 
436
  }
437
 
438
  function getPageCount($p_size, $where="", $table_name){
439
+ if(is_numeric($where))
440
+ return ceil((int)$where / (int)$p_size);
441
+ else
442
+ return ceil((int)$this->getRecordCount($where, $table_name) / (int)$p_size);
443
  }
444
 
445
  function getPage($current_p,$p_size, $where = "", $order_by = '', $table_name){
451
  return $results;
452
  }
453
 
454
+ function get_referer_query($query) {
455
+ if (strpos($query, "google.")) {
456
+ //$pattern = '/^.*\/search.*[\?&]q=(.*)$/';
457
+ $pattern = '/^.*[\?&]q=(.*)$/';
458
+ } else if (strpos($query, "bing.com")) {
459
+ $pattern = '/^.*q=(.*)$/';
460
+ } else if (strpos($query, "yahoo.")) {
461
+ $pattern = '/^.*[\?&]p=(.*)$/';
462
+ } else if (strpos($query, "ask.")) {
463
+ $pattern = '/^.*[\?&]q=(.*)$/';
464
+ } else {
465
+ return false;
466
+ }
467
+ preg_match($pattern, $query, $matches);
468
+ $querystr = substr($matches[1], 0, strpos($matches[1], '&'));
469
+ return urldecode($querystr);
470
+ }
471
+
472
+ function get_referer_info(){
473
+ $referrerinfo = '';
474
+ $keywords = array();
475
+ $i = 1;
476
+ if(isset($_SESSION) and isset($_SESSION['frm_http_referer']) and $_SESSION['frm_http_referer']){
477
+ foreach ($_SESSION['frm_http_referer'] as $referer) {
478
+ $referrerinfo .= str_pad("Referer $i: ",20) . $referer. "\r\n";
479
+ $keywords_used = FrmAppHelper::get_referer_query($referer);
480
+ if ($keywords_used)
481
+ $keywords[] = $keywords_used;
482
+
483
+ $i++;
484
+ }
485
+
486
+ $referrerinfo .= "\r\n";
487
+ }else{
488
+ $referrerinfo = $_SERVER['HTTP_REFERER'];
489
+ }
490
+
491
+ $i = 1;
492
+ if(isset($_SESSION) and isset($_SESSION['frm_http_pages']) and $_SESSION['frm_http_pages']){
493
+ foreach ($_SESSION['frm_http_pages'] as $page) {
494
+ $referrerinfo .= str_pad("Page visited $i: ",20) . $page. "\r\n";
495
+ $i++;
496
+ }
497
+
498
+ $referrerinfo .= "\r\n";
499
+ }
500
+
501
+ $i = 1;
502
+ foreach ($keywords as $keyword) {
503
+ $referrerinfo .= str_pad("Keyword $i: ",20) . $keyword. "\r\n";
504
+ $i++;
505
+ }
506
+ $referrerinfo .= "\r\n";
507
+
508
+ return $referrerinfo;
509
+ }
510
+
511
  }
512
 
513
  ?>
classes/helpers/FrmEntriesHelper.php CHANGED
@@ -3,7 +3,7 @@
3
  class FrmEntriesHelper{
4
 
5
  function setup_new_vars($fields, $form='', $reset=false){
6
- global $frm_form, $frm_settings;
7
  $values = array();
8
  foreach (array('name' => '', 'description' => '', 'item_key' => '') as $var => $default)
9
  $values[$var] = stripslashes(FrmAppHelper::get_param($var, $default));
@@ -11,48 +11,59 @@ class FrmEntriesHelper{
11
  $values['fields'] = array();
12
  if ($fields){
13
  foreach($fields as $field){
14
- $default = $field->default_value;
 
15
 
16
- $field_options = unserialize($field->field_options);
17
- if ($reset)
18
- $new_value = $default;
19
- else
20
- $new_value = ($_POST and isset($_POST['item_meta'][$field->id]) and $_POST['item_meta'][$field->id] != '') ? $_POST['item_meta'][$field->id] : $default;
21
-
22
- $new_value = stripslashes_deep(maybe_unserialize($new_value));
23
- if (!is_array($new_value))
24
- $new_value = apply_filters('frm_get_default_value', $new_value, $field);
25
 
26
- $new_value = str_replace('"', '&quot;', $new_value);
 
 
 
 
27
 
28
- $field_array = array('id' => $field->id,
 
 
 
 
 
 
 
29
  'value' => $new_value,
30
- 'default_value' => $new_value,
31
  'name' => stripslashes($field->name),
32
  'description' => stripslashes($field->description),
33
- 'type' => apply_filters('frm_field_type',$field->type, $field),
34
- 'options' => str_replace('"', '&quot;', stripslashes_deep(unserialize($field->options))),
35
  'required' => $field->required,
36
  'field_key' => $field->field_key,
37
  'field_order' => $field->field_order,
38
- 'form_id' => $field->form_id);
 
39
 
40
- foreach (array('size' => '','max' => '','label' => 'top','invalid' => '','required_indicator' => '','blank' => '', 'clear_on_focus' => 0, 'custom_html' => '', 'default_blank' => 0) as $opt => $default_opt)
41
- $field_array[$opt] = (isset($field_options[$opt]) && $field_options[$opt] != '') ? $field_options[$opt] : $default_opt;
42
 
43
- if ($field_array['custom_html'] == '')
44
- $field_array['custom_html'] = FrmFieldsHelper::get_default_html($field->type);
 
 
 
 
45
 
46
- $values['fields'][] = apply_filters('frm_setup_new_fields_vars', stripslashes_deep($field_array), $field);
47
 
48
- if (!$form or !isset($form->id))
49
- $form = $frm_form->getOne($field->form_id);
50
  }
51
 
52
- $options = stripslashes_deep(unserialize($form->options));
53
-
54
- if (is_array($options)){
55
- foreach ($options as $opt => $value)
56
  $values[$opt] = FrmAppHelper::get_param($opt, $value);
57
  }
58
 
@@ -81,24 +92,26 @@ class FrmEntriesHelper{
81
  }
82
 
83
  function setup_edit_vars($values, $record){
84
- //$values['description'] = unserialize( $record->description );
85
  $values['item_key'] = ($_POST and isset($_POST['item_key']))?$_POST['item_key']:$record->item_key;
86
  $values['form_id'] = $record->form_id;
87
  return apply_filters('frm_setup_edit_entry_vars', $values, $record);
88
  }
89
 
90
  function entries_dropdown( $form_id, $field_name, $field_value='', $blank=true, $blank_label='', $onchange=false ){
91
- global $frm_entry;
92
 
93
- $entries = $frm_entry->getAll("it.form_id=".$form_id,' ORDER BY name');
94
  ?>
95
  <select name="<?php echo $field_name; ?>" id="<?php echo $field_name; ?>" class="frm-dropdown" <?php if ($onchange) echo 'onchange="'.$onchange.'"'; ?>>
96
  <?php if ($blank){ ?>
97
  <option value=""><?php echo $blank_label; ?></option>
98
  <?php } ?>
99
  <?php foreach($entries as $entry){ ?>
100
- <option value="<?php echo $entry->id; ?>" <?php selected($field_value, $entry->id); ?>><?php echo substr((!empty($entry->name)) ? stripslashes($entry->name) : $entry->item_key, 0, 50); ?></option>
101
- <?php } ?>
 
 
102
  </select>
103
  <?php
104
  }
3
  class FrmEntriesHelper{
4
 
5
  function setup_new_vars($fields, $form='', $reset=false){
6
+ global $frm_form, $frm_settings, $frm_sidebar_width;
7
  $values = array();
8
  foreach (array('name' => '', 'description' => '', 'item_key' => '') as $var => $default)
9
  $values[$var] = stripslashes(FrmAppHelper::get_param($var, $default));
11
  $values['fields'] = array();
12
  if ($fields){
13
  foreach($fields as $field){
14
+ $field->field_options = maybe_unserialize($field->field_options);
15
+ $default = $field->default_value;
16
 
17
+ if ($reset)
18
+ $new_value = $default;
19
+ else
20
+ $new_value = ($_POST and isset($_POST['item_meta'][$field->id]) and $_POST['item_meta'][$field->id] != '') ? $_POST['item_meta'][$field->id] : $default;
 
 
 
 
 
21
 
22
+ $is_default = ($new_value == $default) ? true : false;
23
+
24
+ $new_value = stripslashes_deep(maybe_unserialize($new_value));
25
+ if (!is_array($new_value))
26
+ $new_value = apply_filters('frm_get_default_value', $new_value, $field);
27
 
28
+ $new_value = str_replace('"', '&quot;', $new_value);
29
+ if($is_default)
30
+ $field->default_value = $new_value;
31
+ else
32
+ $field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field);
33
+
34
+ $field_array = array(
35
+ 'id' => $field->id,
36
  'value' => $new_value,
37
+ 'default_value' => str_replace('"', '&quot;', maybe_unserialize($field->default_value)),
38
  'name' => stripslashes($field->name),
39
  'description' => stripslashes($field->description),
40
+ 'type' => apply_filters('frm_field_type', $field->type, $field, $new_value),
41
+ 'options' => str_replace('"', '&quot;', stripslashes_deep(maybe_unserialize($field->options))),
42
  'required' => $field->required,
43
  'field_key' => $field->field_key,
44
  'field_order' => $field->field_order,
45
+ 'form_id' => $field->form_id
46
+ );
47
 
48
+ foreach (array('size' => '', 'max' => '', 'label' => 'top', 'invalid' => '', 'required_indicator' => '', 'blank' => '', 'clear_on_focus' => 0, 'custom_html' => '', 'default_blank' => 0) as $opt => $default_opt)
49
+ $field_array[$opt] = (isset($field->field_options[$opt]) && $field->field_options[$opt] != '') ? $field->field_options[$opt] : $default_opt;
50
 
51
+ if ($field_array['size'] == '')
52
+ $field_array['size'] = $frm_sidebar_width;
53
+
54
+
55
+ if ($field_array['custom_html'] == '')
56
+ $field_array['custom_html'] = FrmFieldsHelper::get_default_html($field->type);
57
 
58
+ $values['fields'][] = apply_filters('frm_setup_new_fields_vars', stripslashes_deep($field_array), $field);
59
 
60
+ if (!$form or !isset($form->id))
61
+ $form = $frm_form->getOne($field->form_id);
62
  }
63
 
64
+ $form->options = maybe_unserialize($form->options);
65
+ if (is_array($form->options)){
66
+ foreach ($form->options as $opt => $value)
 
67
  $values[$opt] = FrmAppHelper::get_param($opt, $value);
68
  }
69
 
92
  }
93
 
94
  function setup_edit_vars($values, $record){
95
+ //$values['description'] = maybe_unserialize( $record->description );
96
  $values['item_key'] = ($_POST and isset($_POST['item_key']))?$_POST['item_key']:$record->item_key;
97
  $values['form_id'] = $record->form_id;
98
  return apply_filters('frm_setup_edit_entry_vars', $values, $record);
99
  }
100
 
101
  function entries_dropdown( $form_id, $field_name, $field_value='', $blank=true, $blank_label='', $onchange=false ){
102
+ global $wpdb, $frmdb;
103
 
104
+ $entries = $frmdb->get_records($frmdb->entries, array('form_id' => $form_id), 'name', 999, 'id,item_key,name');
105
  ?>
106
  <select name="<?php echo $field_name; ?>" id="<?php echo $field_name; ?>" class="frm-dropdown" <?php if ($onchange) echo 'onchange="'.$onchange.'"'; ?>>
107
  <?php if ($blank){ ?>
108
  <option value=""><?php echo $blank_label; ?></option>
109
  <?php } ?>
110
  <?php foreach($entries as $entry){ ?>
111
+ <option value="<?php echo $entry->id; ?>" <?php selected($field_value, $entry->id); ?>><?php echo FrmAppHelper::truncate((!empty($entry->name)) ? stripslashes($entry->name) : $entry->item_key, 40); ?></option>
112
+ <?php
113
+ unset($entry);
114
+ } ?>
115
  </select>
116
  <?php
117
  }
classes/helpers/FrmFieldsHelper.php CHANGED
@@ -40,19 +40,18 @@ class FrmFieldsHelper{
40
  //'address' => 'Address' //Address line 1, Address line 2, City, State/Providence, Postal Code, Select Country
41
  //'city_selector' => 'US State/County/City selector',
42
  //'full_name' => 'First and Last Name',
43
- //'terms' => 'Terms of Use',// checkbox or show terms (integrate with Terms of use plugin)
44
  //'quiz' => 'Question and Answer' // for captcha alternative
45
  ));
46
  }
47
 
48
  function setup_new_vars($type='',$form_id=''){
49
- global $frmdb, $frm_app_helper;
50
 
51
- $field_count = $frm_app_helper->getRecordCount("form_id=$form_id", $frmdb->fields);
52
  $key = FrmAppHelper::get_unique_key('', $frmdb->fields, 'field_key');
53
 
54
  $values = array();
55
- foreach (array('name' => __('Untitled', 'formidable'), 'description' => '', 'field_key' => $key, 'type' => $type, 'options'=>'', 'default_value'=>'', 'field_order' => $field_count+1, 'required' => false, 'blank' => __('Untitled cannot be blank', 'formidable'), 'invalid' => __('Untitled is an invalid format', 'formidable'), 'form_id' => $form_id) as $var => $default)
56
  $values[$var] = $default;
57
 
58
  $values['field_options'] = array();
@@ -60,11 +59,13 @@ class FrmFieldsHelper{
60
  $values['field_options'][$var] = $default;
61
 
62
  if ($type == 'radio' || ($type == 'checkbox'))
63
- $values['options'] = serialize(array('Option 1', 'Option 2'));
64
  else if ( $type == 'select')
65
- $values['options'] = serialize(array('','Option 1'));
66
  else if ($type == 'textarea')
67
  $values['field_options']['max'] = '5';
 
 
68
 
69
  return $values;
70
  }
@@ -73,30 +74,37 @@ class FrmFieldsHelper{
73
  global $frm_entry_meta, $frm_form;
74
 
75
  $values = array();
 
 
76
  $values['id'] = $record->id;
77
  $values['form_id'] = $record->form_id;
78
  foreach (array('name' => $record->name, 'description' => $record->description) as $var => $default)
79
  $values[$var] = htmlspecialchars(stripslashes(FrmAppHelper::get_param($var, $default)));
80
 
81
- $values['form_name'] = ($record->form_id)?($frm_form->getName( $record->form_id )):('');
82
 
83
  foreach (array('field_key' => $record->field_key, 'type' => $record->type, 'default_value'=> $record->default_value, 'field_order' => $record->field_order, 'required' => $record->required) as $var => $default)
84
  $values[$var] = FrmAppHelper::get_param($var, $default);
85
 
86
- $field_options = maybe_unserialize($record->field_options);
87
  $values['options'] = stripslashes_deep(maybe_unserialize($record->options));
88
- $values['field_options'] = $field_options;
89
- $values['size'] = (isset($field_options['size']))?($field_options['size']):('');
90
- $values['max'] = (isset($field_options['max']))?($field_options['max']):('');
91
- $values['label'] = (isset($field_options['label']))?($field_options['label']):('top');
92
- $values['blank'] = (isset($field_options['blank']))?($field_options['blank']):('');
93
- $values['required_indicator'] = (isset($field_options['required_indicator']))?($field_options['required_indicator']):('*');
94
- $values['invalid'] = (isset($field_options['invalid']))?($field_options['invalid']):('');
95
- $values['clear_on_focus'] = (isset($field_options['clear_on_focus']))?($field_options['clear_on_focus']):(0);
96
- $values['default_blank'] = (isset($field_options['default_blank']))?($field_options['default_blank']):(0);
97
- $values['custom_html'] = (isset($field_options['custom_html']))? stripslashes($field_options['custom_html']): FrmFieldsHelper::get_default_html($record->type);
98
-
99
- return apply_filters('frm_setup_edit_field_vars',$values);
 
 
 
 
 
 
100
  }
101
 
102
  function get_form_fields($form_id, $error=false){
@@ -107,15 +115,16 @@ class FrmFieldsHelper{
107
  return $fields;
108
  }
109
 
110
- function get_default_html($type){
111
  if (apply_filters('frm_normal_field_type_html', true, $type)){
112
  $default_html = <<<DEFAULT_HTML
113
- <div id="frm_field_[id]_container" class="form-field [required_class] [error_class]">
114
- <label class="frm_pos_[label_position]">[field_name]
115
  <span class="frm_required">[required_label]</span>
116
  </label>
117
  [input]
118
  [if description]<div class="frm_description">[description]</div>[/if description]
 
119
  </div>
120
  DEFAULT_HTML;
121
  }else
@@ -124,7 +133,7 @@ DEFAULT_HTML;
124
  return apply_filters('frm_custom_html', $default_html, $type);
125
  }
126
 
127
- function replace_shortcodes($html, $field, $error_keys=array(), $form=false){
128
  $field_name = "item_meta[". $field['id'] ."]";
129
  //replace [id]
130
  $html = str_replace('[id]', $field['id'], $html);
@@ -132,30 +141,34 @@ DEFAULT_HTML;
132
  //replace [key]
133
  $html = str_replace('[key]', $field['field_key'], $html);
134
 
135
- //replace [description] and [required_label]
136
- $required = ($field['required'] == '0')?(''):($field['required_indicator']);
137
- foreach (array('description' => $field['description'], 'required_label' => $required) as $code => $value){
138
- if ($value == '')
 
139
  $html = preg_replace('/(\[if\s+'.$code.'\])(.*?)(\[\/if\s+'.$code.'\])/mis', '', $html);
140
  else{
141
- $html = str_replace('[if '.$code.']','',$html);
142
- $html = str_replace('[/if '.$code.']','',$html);
143
  }
 
144
  $html = str_replace('['.$code.']', $value, $html);
145
- }
146
 
147
  //replace [required_class]
148
  $required_class = ($field['required'] == '0')?(''):(' form-required');
149
  $html = str_replace('[required_class]', $required_class, $html);
150
 
151
  //replace [label_position]
152
- $html = str_replace('[label_position]', $field['label'], $html);
 
153
 
154
  //replace [field_name]
155
  $html = str_replace('[field_name]', $field['name'], $html);
156
 
157
  //replace [error_class]
158
- $error_class = (in_array('field'.$field['id'], $error_keys)) ? ' frm_blank_field':'';
 
159
  $html = str_replace('[error_class]', $error_class, $html);
160
 
161
  //replace [entry_key]
@@ -200,6 +213,7 @@ DEFAULT_HTML;
200
  //replace [form_name]
201
  $html = str_replace('[form_name]', $form['name'], $html);
202
  }
 
203
 
204
  return apply_filters('frm_replace_shortcodes', $html, $field);
205
  }
@@ -210,11 +224,42 @@ DEFAULT_HTML;
210
  if(!function_exists('recaptcha_get_html'))
211
  require_once(FRM_PATH.'/classes/recaptchalib.php');
212
  ?>
213
- <script type="text/javascript">var RecaptchaOptions={theme:'<?php echo $frm_settings->re_theme ?>',lang:'<?php echo $frm_settings->re_lang ?>'};</script>
214
- <div id="frm_field_<?php echo $field['id'] ?>_container"><?php echo recaptcha_get_html($frm_settings->pubkey, $error, is_ssl()) ?></div>
215
  <?php
216
  }
217
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
218
  function show_onfocus_js($field_id, $clear_on_focus){
219
  global $frm_ajax_url; ?>
220
  <a href="javascript:frm_clear_on_focus(<?php echo $field_id; ?>,<?php echo $clear_on_focus; ?>,'<?php echo FRM_IMAGES_URL ?>','<?php echo $frm_ajax_url?>')" class="<?php echo ($clear_on_focus) ?'':'frm_inactive_icon '; ?>frm-show-hover" id="clear_field_<?php echo $field_id; ?>" title="<?php printf(__('Set this field to %1$sclear on click', 'formidable'), ($clear_on_focus) ? __('not', 'formidable').' ' :'' ); ?>"><img src="<?php echo FRM_IMAGES_URL?>/reload.png"></a>
40
  //'address' => 'Address' //Address line 1, Address line 2, City, State/Providence, Postal Code, Select Country
41
  //'city_selector' => 'US State/County/City selector',
42
  //'full_name' => 'First and Last Name',
 
43
  //'quiz' => 'Question and Answer' // for captcha alternative
44
  ));
45
  }
46
 
47
  function setup_new_vars($type='',$form_id=''){
48
+ global $frmdb, $frm_app_helper, $frm_settings;
49
 
50
+ $field_count = $frm_app_helper->getRecordCount("form_id='$form_id'", $frmdb->fields);
51
  $key = FrmAppHelper::get_unique_key('', $frmdb->fields, 'field_key');
52
 
53
  $values = array();
54
+ foreach (array('name' => __('Untitled', 'formidable'), 'description' => '', 'field_key' => $key, 'type' => $type, 'options'=>'', 'default_value'=>'', 'field_order' => $field_count+1, 'required' => false, 'blank' => __('This field cannot be blank', 'formidable'), 'invalid' => __('This field is invalid', 'formidable'), 'form_id' => $form_id) as $var => $default)
55
  $values[$var] = $default;
56
 
57
  $values['field_options'] = array();
59
  $values['field_options'][$var] = $default;
60
 
61
  if ($type == 'radio' || ($type == 'checkbox'))
62
+ $values['options'] = serialize(array(__('Option 1', 'formidable'), __('Option 2', 'formidable')));
63
  else if ( $type == 'select')
64
+ $values['options'] = serialize(array('', __('Option 1', 'formidable'))); <