Advanced Contact form 7 DB - Version 1.7.0

Version Description

  • We have upgraded with Security patch.
  • Changes related to the premium plugin User Access Manager for the edit case to be handled.
Download this release

Release Info

Developer vsourz1td
Plugin Icon 128x128 Advanced Contact form 7 DB
Version 1.7.0
Comparing to
See all releases

Code changes from version 1.6.2 to 1.7.0

README.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: vsourz1td
3
  Tags: contact form 7 db, advanced cf7 db, contact form 7 database, contact form db, contact form 7, save form data, save contact form, save cf7, database, cf7db, save-contact-form, Save-Forms-Data, import-cf7, export-contact-data, view-cf7-entry
4
  Requires at least: 4.0
5
  Tested up to: 5.2.2
6
- Stable tag: 1.6.2
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -175,6 +175,10 @@ return $contact_form_ids;
175
 
176
  == Changelog ==
177
 
 
 
 
 
178
  = 1.6.2 =
179
  * We have fixed SQL injection related bugs at the back office query.
180
 
3
  Tags: contact form 7 db, advanced cf7 db, contact form 7 database, contact form db, contact form 7, save form data, save contact form, save cf7, database, cf7db, save-contact-form, Save-Forms-Data, import-cf7, export-contact-data, view-cf7-entry
4
  Requires at least: 4.0
5
  Tested up to: 5.2.2
6
+ Stable tag: 1.7.0
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
175
 
176
  == Changelog ==
177
 
178
+ = 1.7.0 =
179
+ * We have upgraded with Security patch.
180
+ * Changes related to the premium plugin **User Access Manager** for the edit case to be handled.
181
+
182
  = 1.6.2 =
183
  * We have fixed SQL injection related bugs at the back office query.
184
 
admin/class-advanced-cf7-db-admin.php CHANGED
@@ -826,9 +826,50 @@ class Advanced_Cf7_Db_Admin {
826
  }//Close admin_init hook function
827
 
828
  //Edit form AJAX call hadle By this function
 
 
 
 
 
829
  public function vsz_cf7_edit_form_ajax(){
830
  //global $cap;
831
  //if(!current_user_can( $cap )) return;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
832
  global $wpdb;
833
  //Check entry id set or not in current request
834
  $rid = ((isset($_POST['rid']) && !empty($_POST['rid'])) ? intval($_POST['rid']) : '');
@@ -850,13 +891,13 @@ class Advanced_Cf7_Db_Admin {
850
  ////Define not editable fields name here
851
  public function vsz_cf7_not_editable_fields_callback(){
852
  $cf7_not_editable_fields = array('submit_time','submit_ip','submit_user_id');
853
-
854
  if(!empty($non_editable)){
855
  foreach($non_editable as $val){
856
  $cf7_not_editable_fields[] = $val;
857
  }
858
  }
859
-
860
  return $cf7_not_editable_fields;
861
  }
862
 
@@ -1476,9 +1517,14 @@ function create_table_cf7_vdata_entry_add_blog(){
1476
  }
1477
 
1478
  // Check user capability
 
 
 
 
 
1479
  function cf7_check_capability($user_capability){
1480
 
1481
- if(is_super_admin()){
1482
  return true;
1483
  }
1484
  $user_id = get_current_user_id();
826
  }//Close admin_init hook function
827
 
828
  //Edit form AJAX call hadle By this function
829
+ /**
830
+ * Change log : 18-07-2019
831
+ * Taken by : @Jaydeep
832
+ * Summary : Added user access checks for the edit case to be handled.
833
+ */
834
  public function vsz_cf7_edit_form_ajax(){
835
  //global $cap;
836
  //if(!current_user_can( $cap )) return;
837
+
838
+ $cap = 'no_access';
839
+ // Check if user have access than display
840
+
841
+ $user_id = get_current_user_id();
842
+ $subject = new WP_User($user_id);
843
+ $allcaps= $subject->allcaps;
844
+ $caps = $subject->caps;
845
+
846
+ $caps = array_merge(wp_get_current_user()->caps, $caps);
847
+ $allcaps = array_merge(wp_get_current_user()->allcaps, $allcaps);
848
+ if (wp_get_current_user()->ID == $subject->ID) {
849
+ wp_get_current_user()->allcaps = $allcaps;
850
+ wp_get_current_user()->caps = $caps;
851
+ }
852
+ $user = wp_get_current_user();
853
+
854
+ //$role = get_role('subscriber');
855
+ //var_dump($user);exit;
856
+ if(isset($user) && !empty($user)){
857
+ foreach($user->allcaps as $key=>$capability){
858
+ if($capability == true){
859
+ if(strpos($key, 'cf7_db_form_edit_') !== false){
860
+ $cap = 'exist';
861
+
862
+ break;
863
+ }
864
+ }
865
+ }
866
+ }
867
+
868
+ if($cap == 'no_access' ){
869
+ echo json_encode('@@You do not have access to edit the data.');
870
+ exit;
871
+ }
872
+
873
  global $wpdb;
874
  //Check entry id set or not in current request
875
  $rid = ((isset($_POST['rid']) && !empty($_POST['rid'])) ? intval($_POST['rid']) : '');
891
  ////Define not editable fields name here
892
  public function vsz_cf7_not_editable_fields_callback(){
893
  $cf7_not_editable_fields = array('submit_time','submit_ip','submit_user_id');
894
+
895
  if(!empty($non_editable)){
896
  foreach($non_editable as $val){
897
  $cf7_not_editable_fields[] = $val;
898
  }
899
  }
900
+
901
  return $cf7_not_editable_fields;
902
  }
903
 
1517
  }
1518
 
1519
  // Check user capability
1520
+ /**
1521
+ * Change log : 18-07-2019
1522
+ * Taken by : @Jaydeep
1523
+ * Summary : Added the multisite check
1524
+ */
1525
  function cf7_check_capability($user_capability){
1526
 
1527
+ if(is_super_admin() && is_multisite()){
1528
  return true;
1529
  }
1530
  $user_id = get_current_user_id();
admin/js/advanced-cf7-db-admin.js CHANGED
@@ -44,7 +44,7 @@ function submit_cf7(){
44
 
45
  //Select form name then call
46
  function import_submit_cf7(){
47
-
48
  var url = jQuery('#base_url').val();
49
  var cf7_id = parseInt(jQuery('#import_cf7_id').val());
50
  if(!isNaN(cf7_id)){
@@ -68,12 +68,12 @@ function checkfile(sender) {
68
  }
69
 
70
  jQuery(document).ready(function($) {
71
-
72
  //Set date picker on listing screen
73
  jQuery("#start_date").datetimepicker({
74
-
75
  timepicker:false,
76
- format:'d/m/Y',
77
  maxDate: "0",
78
  changeMonth: true,
79
  changeYear: true,
@@ -81,21 +81,21 @@ jQuery(document).ready(function($) {
81
  scrollInput: false,
82
  });
83
  jQuery("#end_date").datetimepicker({
84
-
85
  timepicker:false,
86
- format:'d/m/Y',
87
  maxDate: "0",
88
  changeMonth: true,
89
  changeYear: true,
90
  closeOnDateSelect: true,
91
  scrollInput: false,
92
  });
93
-
94
  //Setup date filter text box is readonly
95
  jQuery(".input-cf-date").attr("readonly","true");
96
  jQuery(".input-cf-date").css("background-color","#fff");
97
-
98
-
99
  //Setup icon functionality in setting page
100
  jQuery('#cf7d-list-field li span.dashicons').click(function(event) {
101
  var $this = jQuery(this);
@@ -112,13 +112,13 @@ jQuery(document).ready(function($) {
112
  $custom_label.val('1');
113
  }
114
  });
115
-
116
  /////////// For Date filter condition here/////////////
117
  jQuery('#search_date').click(function(event) {
118
  var startDate = document.getElementById('start_date');
119
  var endDate = document.getElementById('end_date');
120
  formCheck = true;
121
-
122
  if(startDate.value == ''){
123
  startDate.style.border = 'solid 1px red';
124
  startDate.value = '';
@@ -128,7 +128,7 @@ jQuery(document).ready(function($) {
128
  else{
129
  startDate.style.border = '';
130
  }
131
-
132
  if(endDate.value == ''){
133
  endDate.style.border = 'solid 1px red';
134
  endDate.value = '';
@@ -138,23 +138,23 @@ jQuery(document).ready(function($) {
138
  else{
139
  endDate.style.border = '';
140
  }
141
-
142
  //Detailed check for valid date ranges
143
  var dayfield=startDate.value.split("/")[0];
144
  var monthfield=startDate.value.split("/")[1];
145
  var yearfield=startDate.value.split("/")[2];
146
-
147
  var edayfield=endDate.value.split("/")[0];
148
  var emonthfield=endDate.value.split("/")[1];
149
  var eyearfield=endDate.value.split("/")[2];
150
-
151
  if(formCheck && (new Date(yearfield, monthfield-1, dayfield).getTime() > new Date(eyearfield, emonthfield-1, edayfield).getTime())){
152
  endDate.style.border = 'solid 1px red';
153
  endDate.value = '';
154
  endDate.focus();
155
  formCheck = false;
156
  }
157
-
158
  if(formCheck){
159
  endDate.style.border = '';
160
  jQuery('#cf7d-admin-action-frm').submit();
@@ -162,34 +162,34 @@ jQuery(document).ready(function($) {
162
  else{
163
  return false;
164
  }
165
-
166
  });
167
-
168
-
169
  /*
170
- * Edit value
171
  */
172
  jQuery('a.cf7d-edit-value').click(function(event) {
173
-
174
-
175
  jQuery('#cf7d-modal-form-edit-value').removeClass('loading');
176
  jQuery('body').addClass('our-body-class');
177
-
178
  document.getElementById('overlayLoader').style.display = "block";
179
  var rid = parseInt(jQuery(this).data('rid'));
180
-
181
  var arr_field_type = jQuery.parseJSON(jQuery('form#cf7d-modal-form-edit-value input[name="arr_field_type"]').val());
182
  var arr_option = ['radio','checkbox','select'];
183
  //console.log(arr_field_type);
184
  jQuery('form#cf7d-modal-form-edit-value input[name="rid"]').attr('value', rid);
185
  rs = jQuery('form#cf7d-modal-form-edit-value input[class^="field-"]');
186
  var arr_text = jQuery('form#cf7d-modal-form-edit-value textarea[class^="field-"]');
187
-
188
  //Set all fields value is loading
189
  for(var fieldname in arr_field_type){
190
  if(Object.keys(arr_field_type[fieldname]).length == 1){
191
  //if(!arr_option.includes(arr_field_type[fieldname])){
192
- //check field type is not text and file
193
  if(arr_field_type[fieldname]['basetype'] != 'text' && arr_field_type[fieldname]['basetype'] != 'file'){
194
  jQuery('form#cf7d-modal-form-edit-value textarea[class^="field-'+fieldname+'"]').html('Loading...');
195
  }
@@ -210,7 +210,7 @@ jQuery(document).ready(function($) {
210
  jQuery('form#cf7d-modal-form-edit-value textarea[class^="field-'+fieldname+'"]').html('Loading...');
211
  }
212
  }
213
-
214
  //Call Ajax request here for get entry related information
215
  jQuery.ajax({
216
  url: ajaxurl + '?action=vsz_cf7_edit_form_value',
@@ -220,17 +220,23 @@ jQuery(document).ready(function($) {
220
  .done(function(data) {
221
  //Decode json data here
222
  var json = jQuery.parseJSON(data);
 
 
 
 
 
 
223
  //Set fields value
224
  jQuery.each(json, function(index, el){
225
  //Get existing fields information
226
  if(index in arr_field_type){
227
-
228
  //Check existing field length for field type is check box or radio button
229
  //if(Object.keys(arr_field_type[index]).length > 1){
230
  if(false && arr_option.includes(arr_field_type[index]['basetype'])){
231
  //Get all existing checkboxes values
232
  var arr_checkbox = jQuery('form#cf7d-modal-form-edit-value input[class^="field-'+index+'"]');
233
- //Set option box values
234
  //if(arr_checkbox.length == 0){
235
  if(arr_field_type[index]['basetype'] == 'select'){
236
  jQuery('form#cf7d-modal-form-edit-value select option[value="'+el+'"]').prop('selected', true);
@@ -240,7 +246,7 @@ jQuery(document).ready(function($) {
240
  arr_values = el.split('\n');
241
  //Add or remove checked attributes on check boxes
242
  jQuery.each(arr_checkbox, function(indexc, elc){
243
- //Set checked value check boxes
244
  if(arr_values != '' && arr_values.includes(jQuery(this).val())){
245
  jQuery(this).attr('checked','checked');
246
  }
@@ -250,7 +256,7 @@ jQuery(document).ready(function($) {
250
  });
251
  }
252
  }
253
- //Set file field related functionality here
254
  else if(arr_field_type[index]['basetype'] == 'file'){
255
  if(el){
256
  var filename = el.split('/').pop();
@@ -274,12 +280,12 @@ jQuery(document).ready(function($) {
274
  jQuery('form#cf7d-modal-form-edit-value .field-' + index).html(el);
275
  }
276
  }
277
- else{
278
- jQuery('form#cf7d-modal-form-edit-value .field-' + index).attr('value', el);
279
  }
280
-
281
  });
282
-
283
  //Remove Loading word on all fields values
284
  jQuery.each(rs, function(index, el){
285
  if(jQuery(this).val() == 'Loading...'){
@@ -289,14 +295,14 @@ jQuery(document).ready(function($) {
289
  }
290
  }
291
  });
292
-
293
- //Remove text area to loading value
294
  jQuery.each(arr_text, function(index, el){
295
  if(jQuery(this).val() == 'Loading...'){
296
  jQuery(this).val('');
297
  }
298
  });
299
-
300
  //setTimeout(function(){ document.getElementById('overlayLoader').style.display = "none"; }, 1000);
301
  })
302
  .fail(function() {
@@ -306,10 +312,10 @@ jQuery(document).ready(function($) {
306
  console.log("complete");
307
  document.getElementById('overlayLoader').style.display = "none";
308
  });
309
-
310
  });
311
-
312
- //Add email field validation on Edit form
313
  jQuery('#update_cf7_value').click(function(){
314
  var arr_field_type = jQuery.parseJSON(jQuery('form#cf7d-modal-form-edit-value input[name="arr_field_type"]').val());
315
  var flagReturn =true;
@@ -330,7 +336,7 @@ jQuery(document).ready(function($) {
330
  }
331
  return false;
332
  });
333
-
334
  /*
335
  * Search
336
  */
@@ -346,36 +352,36 @@ jQuery(document).ready(function($) {
346
  return false;
347
  }
348
  });
349
-
350
  });
351
 
352
  //Define valid email address function here
353
  function validateEmail(email) {
354
-
355
  var expr = /^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,10}|[0-9]{1,3})(\]?)$/;
356
  return expr.test(email);
357
  };
358
 
359
  // Define add remove file for edit section
360
  function add_remove_file(index,filename){
361
-
362
  if(filename != ""){
363
  jQuery('form#cf7d-modal-form-edit-value .field-' + index).show();
364
  jQuery('form#cf7d-modal-form-edit-value .field-' + index).parent().find(".vsz_cf7_db_file_edit").each(function(){
365
  jQuery(this).click(function(){
366
  if(confirm("Are you sure to remove the file? File will be deleted permanently and could not be retrieved.")){
367
-
368
  var fid = jQuery("input[name='fid']").val();
369
  var rid = jQuery("input[name='rid']").val();
370
  var field = index;
371
-
372
  var fd = new FormData();
373
  fd.append( "fid", fid);
374
  fd.append( "rid", rid);
375
  fd.append( "field", field);
376
  fd.append( "val", filename);
377
  fd.append( "action", "acf7_db_edit_scr_file_delete");
378
-
379
  jQuery.ajax({
380
  url: ajaxurl,
381
  type: 'POST',
@@ -390,26 +396,26 @@ function add_remove_file(index,filename){
390
  jQuery('form#cf7d-modal-form-edit-value .field-' + index).parent().find('a').remove();
391
  jQuery('form#cf7d-modal-form-edit-value .field-' + index).parent().append('<span class="margin_left">Maximum file size allowed : 7.60 MB.</span><span class="margin_left" style="display: block;">It is possible that server has limit less than 7.60 MB, in that case it can terminate the request. It is advisable to keep upload file size as minimum as possible.</span>');
392
  jQuery('form#cf7d-modal-form-edit-value .field-' + index).hide();
393
-
394
  document.getElementById('overlayLoader').style.display = "none";
395
-
396
  jQuery(".field-"+index+"-val").change(function(){
397
  var thisdata = jQuery(this);
398
  var fileName = jQuery(thisdata).val();
399
  var checkvalidate = 1;
400
-
401
  if(fileName != "" && fileName != undefined){
402
  var fd = new FormData();
403
  var fid = jQuery("input[name='fid']").val();
404
  var rid = jQuery("input[name='rid']").val();
405
  var field = index;
406
-
407
  fd.append( "image", jQuery(thisdata)[0].files[0]);
408
  fd.append( "action", "acf7_db_edit_scr_file_upload");
409
  fd.append( "fid", fid);
410
  fd.append( "rid", rid);
411
  fd.append( "field", field);
412
-
413
  jQuery.ajax({
414
  url: ajaxurl,
415
  type: 'POST',
@@ -432,10 +438,10 @@ function add_remove_file(index,filename){
432
  }
433
  else{
434
  dataArr = data.split("~~@@~~&&~~");
435
-
436
  var filename = dataArr[0];
437
  var el = dataArr[1];
438
-
439
  jQuery('form#cf7d-modal-form-edit-value .field-' + index).attr('value', filename);
440
  jQuery('form#cf7d-modal-form-edit-value .field-' + index).css("border","");
441
  jQuery('form#cf7d-modal-form-edit-value .field-' + index).parent().append('<a class="margin_left" href="'+el+'" target="_blank" download >Download</a>');
@@ -443,11 +449,11 @@ function add_remove_file(index,filename){
443
  jQuery('form#cf7d-modal-form-edit-value .field-' + index).show();
444
  jQuery('form#cf7d-modal-form-edit-value .field-' + index).parent().find('.field-'+index+'-val').remove();
445
  jQuery('form#cf7d-modal-form-edit-value .field-' + index).parent().find('span.margin_left').remove();
446
-
447
  // Calling function which will handle the removal and new upload of the files
448
  add_remove_file(index,filename);
449
  }
450
-
451
  document.getElementById('overlayLoader').style.display = "none";
452
  },
453
 
@@ -468,7 +474,7 @@ function add_remove_file(index,filename){
468
  return false;
469
  },
470
  });
471
-
472
  }
473
  });
474
  });
@@ -478,26 +484,26 @@ function add_remove_file(index,filename){
478
  jQuery('form#cf7d-modal-form-edit-value .field-' + index).parent().find('a').remove();
479
  jQuery('form#cf7d-modal-form-edit-value .field-' + index).parent().append('<span class="margin_left">Maximum file size allowed : 7.60 MB.</span><span class="margin_left" style="display: block;">It is possible that server has limit less than 7.60 MB, in that case it can terminate the request. It is advisable to keep upload file size as minimum as possible.</span>');
480
  jQuery('form#cf7d-modal-form-edit-value .field-' + index).hide();
481
-
482
  document.getElementById('overlayLoader').style.display = "none";
483
-
484
  jQuery(".field-"+index+"-val").change(function(){
485
  var thisdata = jQuery(this);
486
  var fileName = jQuery(thisdata).val();
487
  var checkvalidate = 1;
488
-
489
  if(fileName != "" && fileName != undefined){
490
  var fd = new FormData();
491
  var fid = jQuery("input[name='fid']").val();
492
  var rid = jQuery("input[name='rid']").val();
493
  var field = index;
494
-
495
  fd.append( "image", jQuery(thisdata)[0].files[0]);
496
  fd.append( "action", "acf7_db_edit_scr_file_upload");
497
  fd.append( "fid", fid);
498
  fd.append( "rid", rid);
499
  fd.append( "field", field);
500
-
501
  jQuery.ajax({
502
  url: ajaxurl,
503
  type: 'POST',
@@ -520,10 +526,10 @@ function add_remove_file(index,filename){
520
  }
521
  else{
522
  dataArr = data.split("~~@@~~&&~~");
523
-
524
  var filename = dataArr[0];
525
  var el = dataArr[1];
526
-
527
  jQuery('form#cf7d-modal-form-edit-value .field-' + index).attr('value', filename);
528
  jQuery('form#cf7d-modal-form-edit-value .field-' + index).css("border","");
529
  jQuery('form#cf7d-modal-form-edit-value .field-' + index).parent().append('<a class="margin_left" href="'+el+'" target="_blank" download >Download</a>');
@@ -531,11 +537,11 @@ function add_remove_file(index,filename){
531
  jQuery('form#cf7d-modal-form-edit-value .field-' + index).show();
532
  jQuery('form#cf7d-modal-form-edit-value .field-' + index).parent().find('.field-'+index+'-val').remove();
533
  jQuery('form#cf7d-modal-form-edit-value .field-' + index).parent().find('span.margin_left').remove();
534
-
535
  // Calling function which will handle the removal and new upload of the files
536
  add_remove_file(index,filename);
537
  }
538
-
539
  document.getElementById('overlayLoader').style.display = "none";
540
  },
541
 
@@ -554,13 +560,13 @@ function add_remove_file(index,filename){
554
  /**************** Check fields key related match key value empty or not *************************/
555
  jQuery(document).ready(function() {
556
 
557
- //Get current page information
558
  var active_sub_menu = jQuery('.pagination-links').find('span');
559
  if(active_sub_menu.hasClass('current') ){ // .hasClass() returns BOOLEAN true/false
560
  page_id = parseInt(jQuery('.pagination-links .current').html());
561
  jQuery('.pagination-links .current').html('<input type="number" step="1" min="1" class="tiny-text" name="current_page" id="current_page" value="'+page_id+'" size="1" aria-describedby="table-paging">');
562
  }
563
-
564
  //When enter key press on page number text field then form submit with new information
565
  jQuery('#current_page').keydown(function(e){
566
  if(e.which === 13){
@@ -569,18 +575,18 @@ jQuery(document).ready(function() {
569
  var totalPage = parseInt(jQuery('#totalPage').val().trim());
570
  if(new_val <= totalPage){
571
  jQuery('#cpage').val(new_val);
572
- document.getElementById('cf7d-admin-action-frm').submit();
573
  }
574
  }
575
  return false;
576
  }
577
  });
578
-
579
  jQuery('#import_sheet').on('click',function(){
580
  var count = 0;
581
  jQuery(".match-key").each(function() {
582
  if(jQuery(this).val()){
583
- count ++;
584
  }
585
  });
586
  if(count){
@@ -609,9 +615,9 @@ function get_list_fields(form_id){
609
  document.getElementById('overlayLoader').style.display = "block";
610
  },
611
  success: function(data) {
612
-
613
  alert(data);
614
-
615
  document.getElementById('overlayLoader').style.display = "none";
616
  },
617
  error: function(data){
44
 
45
  //Select form name then call
46
  function import_submit_cf7(){
47
+
48
  var url = jQuery('#base_url').val();
49
  var cf7_id = parseInt(jQuery('#import_cf7_id').val());
50
  if(!isNaN(cf7_id)){
68
  }
69
 
70
  jQuery(document).ready(function($) {
71
+
72
  //Set date picker on listing screen
73
  jQuery("#start_date").datetimepicker({
74
+
75
  timepicker:false,
76
+ format:'d/m/Y',
77
  maxDate: "0",
78
  changeMonth: true,
79
  changeYear: true,
81
  scrollInput: false,
82
  });
83
  jQuery("#end_date").datetimepicker({
84
+
85
  timepicker:false,
86
+ format:'d/m/Y',
87
  maxDate: "0",
88
  changeMonth: true,
89
  changeYear: true,
90
  closeOnDateSelect: true,
91
  scrollInput: false,
92
  });
93
+
94
  //Setup date filter text box is readonly
95
  jQuery(".input-cf-date").attr("readonly","true");
96
  jQuery(".input-cf-date").css("background-color","#fff");
97
+
98
+
99
  //Setup icon functionality in setting page
100
  jQuery('#cf7d-list-field li span.dashicons').click(function(event) {
101
  var $this = jQuery(this);
112
  $custom_label.val('1');
113
  }
114
  });
115
+
116
  /////////// For Date filter condition here/////////////
117
  jQuery('#search_date').click(function(event) {
118
  var startDate = document.getElementById('start_date');
119
  var endDate = document.getElementById('end_date');
120
  formCheck = true;
121
+
122
  if(startDate.value == ''){
123
  startDate.style.border = 'solid 1px red';
124
  startDate.value = '';
128
  else{
129
  startDate.style.border = '';
130
  }
131
+
132
  if(endDate.value == ''){
133
  endDate.style.border = 'solid 1px red';
134
  endDate.value = '';
138
  else{
139
  endDate.style.border = '';
140
  }
141
+
142
  //Detailed check for valid date ranges
143
  var dayfield=startDate.value.split("/")[0];
144
  var monthfield=startDate.value.split("/")[1];
145
  var yearfield=startDate.value.split("/")[2];
146
+
147
  var edayfield=endDate.value.split("/")[0];
148
  var emonthfield=endDate.value.split("/")[1];
149
  var eyearfield=endDate.value.split("/")[2];
150
+
151
  if(formCheck && (new Date(yearfield, monthfield-1, dayfield).getTime() > new Date(eyearfield, emonthfield-1, edayfield).getTime())){
152
  endDate.style.border = 'solid 1px red';
153
  endDate.value = '';
154
  endDate.focus();
155
  formCheck = false;
156
  }
157
+
158
  if(formCheck){
159
  endDate.style.border = '';
160
  jQuery('#cf7d-admin-action-frm').submit();
162
  else{
163
  return false;
164
  }
165
+
166
  });
167
+
168
+
169
  /*
170
+ * Edit value
171
  */
172
  jQuery('a.cf7d-edit-value').click(function(event) {
173
+
174
+
175
  jQuery('#cf7d-modal-form-edit-value').removeClass('loading');
176
  jQuery('body').addClass('our-body-class');
177
+
178
  document.getElementById('overlayLoader').style.display = "block";
179
  var rid = parseInt(jQuery(this).data('rid'));
180
+
181
  var arr_field_type = jQuery.parseJSON(jQuery('form#cf7d-modal-form-edit-value input[name="arr_field_type"]').val());
182
  var arr_option = ['radio','checkbox','select'];
183
  //console.log(arr_field_type);
184
  jQuery('form#cf7d-modal-form-edit-value input[name="rid"]').attr('value', rid);
185
  rs = jQuery('form#cf7d-modal-form-edit-value input[class^="field-"]');
186
  var arr_text = jQuery('form#cf7d-modal-form-edit-value textarea[class^="field-"]');
187
+
188
  //Set all fields value is loading
189
  for(var fieldname in arr_field_type){
190
  if(Object.keys(arr_field_type[fieldname]).length == 1){
191
  //if(!arr_option.includes(arr_field_type[fieldname])){
192
+ //check field type is not text and file
193
  if(arr_field_type[fieldname]['basetype'] != 'text' && arr_field_type[fieldname]['basetype'] != 'file'){
194
  jQuery('form#cf7d-modal-form-edit-value textarea[class^="field-'+fieldname+'"]').html('Loading...');
195
  }
210
  jQuery('form#cf7d-modal-form-edit-value textarea[class^="field-'+fieldname+'"]').html('Loading...');
211
  }
212
  }
213
+
214
  //Call Ajax request here for get entry related information
215
  jQuery.ajax({
216
  url: ajaxurl + '?action=vsz_cf7_edit_form_value',
220
  .done(function(data) {
221
  //Decode json data here
222
  var json = jQuery.parseJSON(data);
223
+ if(json.indexOf('@@') != -1){
224
+ alert('You do not have the access to edit the data.');
225
+ document.getElementById('overlayLoader').style.display = "none";
226
+ self.parent.tb_remove();
227
+ return false;
228
+ }
229
  //Set fields value
230
  jQuery.each(json, function(index, el){
231
  //Get existing fields information
232
  if(index in arr_field_type){
233
+
234
  //Check existing field length for field type is check box or radio button
235
  //if(Object.keys(arr_field_type[index]).length > 1){
236
  if(false && arr_option.includes(arr_field_type[index]['basetype'])){
237
  //Get all existing checkboxes values
238
  var arr_checkbox = jQuery('form#cf7d-modal-form-edit-value input[class^="field-'+index+'"]');
239
+ //Set option box values
240
  //if(arr_checkbox.length == 0){
241
  if(arr_field_type[index]['basetype'] == 'select'){
242
  jQuery('form#cf7d-modal-form-edit-value select option[value="'+el+'"]').prop('selected', true);
246
  arr_values = el.split('\n');
247
  //Add or remove checked attributes on check boxes
248
  jQuery.each(arr_checkbox, function(indexc, elc){
249
+ //Set checked value check boxes
250
  if(arr_values != '' && arr_values.includes(jQuery(this).val())){
251
  jQuery(this).attr('checked','checked');
252
  }
256
  });
257
  }
258
  }
259
+ //Set file field related functionality here
260
  else if(arr_field_type[index]['basetype'] == 'file'){
261
  if(el){
262
  var filename = el.split('/').pop();
280
  jQuery('form#cf7d-modal-form-edit-value .field-' + index).html(el);
281
  }
282
  }
283
+ else{
284
+ jQuery('form#cf7d-modal-form-edit-value .field-' + index).attr('value', el);
285
  }
286
+
287
  });
288
+
289
  //Remove Loading word on all fields values
290
  jQuery.each(rs, function(index, el){
291
  if(jQuery(this).val() == 'Loading...'){
295
  }
296
  }
297
  });
298
+
299
+ //Remove text area to loading value
300
  jQuery.each(arr_text, function(index, el){
301
  if(jQuery(this).val() == 'Loading...'){
302
  jQuery(this).val('');
303
  }
304
  });
305
+
306
  //setTimeout(function(){ document.getElementById('overlayLoader').style.display = "none"; }, 1000);
307
  })
308
  .fail(function() {
312
  console.log("complete");
313
  document.getElementById('overlayLoader').style.display = "none";
314
  });
315
+
316
  });
317
+
318
+ //Add email field validation on Edit form
319
  jQuery('#update_cf7_value').click(function(){
320
  var arr_field_type = jQuery.parseJSON(jQuery('form#cf7d-modal-form-edit-value input[name="arr_field_type"]').val());
321
  var flagReturn =true;
336
  }
337
  return false;
338
  });
339
+
340
  /*
341
  * Search
342
  */
352
  return false;
353
  }
354
  });
355
+
356
  });
357
 
358
  //Define valid email address function here
359
  function validateEmail(email) {
360
+
361
  var expr = /^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,10}|[0-9]{1,3})(\]?)$/;
362
  return expr.test(email);
363
  };
364
 
365
  // Define add remove file for edit section
366
  function add_remove_file(index,filename){
367
+
368
  if(filename != ""){
369
  jQuery('form#cf7d-modal-form-edit-value .field-' + index).show();
370
  jQuery('form#cf7d-modal-form-edit-value .field-' + index).parent().find(".vsz_cf7_db_file_edit").each(function(){
371
  jQuery(this).click(function(){
372
  if(confirm("Are you sure to remove the file? File will be deleted permanently and could not be retrieved.")){
373
+
374
  var fid = jQuery("input[name='fid']").val();
375
  var rid = jQuery("input[name='rid']").val();
376
  var field = index;
377
+
378
  var fd = new FormData();
379
  fd.append( "fid", fid);
380
  fd.append( "rid", rid);
381
  fd.append( "field", field);
382
  fd.append( "val", filename);
383
  fd.append( "action", "acf7_db_edit_scr_file_delete");
384
+
385
  jQuery.ajax({
386
  url: ajaxurl,
387
  type: 'POST',
396
  jQuery('form#cf7d-modal-form-edit-value .field-' + index).parent().find('a').remove();
397
  jQuery('form#cf7d-modal-form-edit-value .field-' + index).parent().append('<span class="margin_left">Maximum file size allowed : 7.60 MB.</span><span class="margin_left" style="display: block;">It is possible that server has limit less than 7.60 MB, in that case it can terminate the request. It is advisable to keep upload file size as minimum as possible.</span>');
398
  jQuery('form#cf7d-modal-form-edit-value .field-' + index).hide();
399
+
400
  document.getElementById('overlayLoader').style.display = "none";
401
+
402
  jQuery(".field-"+index+"-val").change(function(){
403
  var thisdata = jQuery(this);
404
  var fileName = jQuery(thisdata).val();
405
  var checkvalidate = 1;
406
+
407
  if(fileName != "" && fileName != undefined){
408
  var fd = new FormData();
409
  var fid = jQuery("input[name='fid']").val();
410
  var rid = jQuery("input[name='rid']").val();
411
  var field = index;
412
+
413
  fd.append( "image", jQuery(thisdata)[0].files[0]);
414
  fd.append( "action", "acf7_db_edit_scr_file_upload");
415
  fd.append( "fid", fid);
416
  fd.append( "rid", rid);
417
  fd.append( "field", field);
418
+
419
  jQuery.ajax({
420
  url: ajaxurl,
421
  type: 'POST',
438
  }
439
  else{
440
  dataArr = data.split("~~@@~~&&~~");
441
+
442
  var filename = dataArr[0];
443
  var el = dataArr[1];
444
+
445
  jQuery('form#cf7d-modal-form-edit-value .field-' + index).attr('value', filename);
446
  jQuery('form#cf7d-modal-form-edit-value .field-' + index).css("border","");
447
  jQuery('form#cf7d-modal-form-edit-value .field-' + index).parent().append('<a class="margin_left" href="'+el+'" target="_blank" download >Download</a>');
449
  jQuery('form#cf7d-modal-form-edit-value .field-' + index).show();
450
  jQuery('form#cf7d-modal-form-edit-value .field-' + index).parent().find('.field-'+index+'-val').remove();
451
  jQuery('form#cf7d-modal-form-edit-value .field-' + index).parent().find('span.margin_left').remove();
452
+
453
  // Calling function which will handle the removal and new upload of the files
454
  add_remove_file(index,filename);
455
  }
456
+
457
  document.getElementById('overlayLoader').style.display = "none";
458
  },
459
 
474
  return false;
475
  },
476
  });
477
+
478
  }
479
  });
480
  });
484
  jQuery('form#cf7d-modal-form-edit-value .field-' + index).parent().find('a').remove();
485
  jQuery('form#cf7d-modal-form-edit-value .field-' + index).parent().append('<span class="margin_left">Maximum file size allowed : 7.60 MB.</span><span class="margin_left" style="display: block;">It is possible that server has limit less than 7.60 MB, in that case it can terminate the request. It is advisable to keep upload file size as minimum as possible.</span>');
486
  jQuery('form#cf7d-modal-form-edit-value .field-' + index).hide();
487
+
488
  document.getElementById('overlayLoader').style.display = "none";
489
+
490
  jQuery(".field-"+index+"-val").change(function(){
491
  var thisdata = jQuery(this);
492
  var fileName = jQuery(thisdata).val();
493
  var checkvalidate = 1;
494
+
495
  if(fileName != "" && fileName != undefined){
496
  var fd = new FormData();
497
  var fid = jQuery("input[name='fid']").val();
498
  var rid = jQuery("input[name='rid']").val();
499
  var field = index;
500
+
501
  fd.append( "image", jQuery(thisdata)[0].files[0]);
502
  fd.append( "action", "acf7_db_edit_scr_file_upload");
503
  fd.append( "fid", fid);
504
  fd.append( "rid", rid);
505
  fd.append( "field", field);
506
+
507
  jQuery.ajax({
508
  url: ajaxurl,
509
  type: 'POST',
526
  }
527
  else{
528
  dataArr = data.split("~~@@~~&&~~");
529
+
530
  var filename = dataArr[0];
531
  var el = dataArr[1];
532
+
533
  jQuery('form#cf7d-modal-form-edit-value .field-' + index).attr('value', filename);
534
  jQuery('form#cf7d-modal-form-edit-value .field-' + index).css("border","");
535
  jQuery('form#cf7d-modal-form-edit-value .field-' + index).parent().append('<a class="margin_left" href="'+el+'" target="_blank" download >Download</a>');
537
  jQuery('form#cf7d-modal-form-edit-value .field-' + index).show();
538
  jQuery('form#cf7d-modal-form-edit-value .field-' + index).parent().find('.field-'+index+'-val').remove();
539
  jQuery('form#cf7d-modal-form-edit-value .field-' + index).parent().find('span.margin_left').remove();
540
+
541
  // Calling function which will handle the removal and new upload of the files
542
  add_remove_file(index,filename);
543
  }
544
+
545
  document.getElementById('overlayLoader').style.display = "none";
546
  },
547
 
560
  /**************** Check fields key related match key value empty or not *************************/
561
  jQuery(document).ready(function() {
562
 
563
+ //Get current page information
564
  var active_sub_menu = jQuery('.pagination-links').find('span');
565
  if(active_sub_menu.hasClass('current') ){ // .hasClass() returns BOOLEAN true/false
566
  page_id = parseInt(jQuery('.pagination-links .current').html());
567
  jQuery('.pagination-links .current').html('<input type="number" step="1" min="1" class="tiny-text" name="current_page" id="current_page" value="'+page_id+'" size="1" aria-describedby="table-paging">');
568
  }
569
+
570
  //When enter key press on page number text field then form submit with new information
571
  jQuery('#current_page').keydown(function(e){
572
  if(e.which === 13){
575
  var totalPage = parseInt(jQuery('#totalPage').val().trim());
576
  if(new_val <= totalPage){
577
  jQuery('#cpage').val(new_val);
578
+ document.getElementById('cf7d-admin-action-frm').submit();
579
  }
580
  }
581
  return false;
582
  }
583
  });
584
+
585
  jQuery('#import_sheet').on('click',function(){
586
  var count = 0;
587
  jQuery(".match-key").each(function() {
588
  if(jQuery(this).val()){
589
+ count ++;
590
  }
591
  });
592
  if(count){
615
  document.getElementById('overlayLoader').style.display = "block";
616
  },
617
  success: function(data) {
618
+
619
  alert(data);
620
+
621
  document.getElementById('overlayLoader').style.display = "none";
622
  },
623
  error: function(data){
advanced-cf7-db.php CHANGED
@@ -9,7 +9,7 @@
9
  * Plugin Name: Advanced CF7 DB
10
  * Plugin URI: https://wordpress.org/plugins/advanced-cf7-db/
11
  * Description: Save all contact form 7 submitted data to the database, View, Export, ordering, Change field labels, Import data using CSV very easily.
12
- * Version: 1.6.2
13
  * Author: Vsourz Digital
14
  * Author URI: https://www.vsourz.com
15
  * License: GPL-2.0+
@@ -23,7 +23,7 @@ if ( ! defined( 'WPINC' ) ) {
23
  die;
24
  }
25
  global $vsz_cf7db_current_version;
26
- $vsz_cf7db_current_version = '1.6.2';
27
  /**
28
  * Defining all the table names and setting their prefix here
29
  */
9
  * Plugin Name: Advanced CF7 DB
10
  * Plugin URI: https://wordpress.org/plugins/advanced-cf7-db/
11
  * Description: Save all contact form 7 submitted data to the database, View, Export, ordering, Change field labels, Import data using CSV very easily.
12
+ * Version: 1.7.0
13
  * Author: Vsourz Digital
14
  * Author URI: https://www.vsourz.com
15
  * License: GPL-2.0+
23
  die;
24
  }
25
  global $vsz_cf7db_current_version;
26
+ $vsz_cf7db_current_version = '1.7.0';
27
  /**
28
  * Defining all the table names and setting their prefix here
29
  */