Version Description
- Fixed issue related to export records in PDF.
- Provided filter for excluding particular contact form entry to the database
- Provided filter to add, modify, remove CF7 fields and data before submitting to the database.
Download this release
Release Info
Developer | vsourz1td |
Plugin | Advanced Contact form 7 DB |
Version | 1.4.4 |
Comparing to | |
See all releases |
Code changes from version 1.4.3 to 1.4.4
- README.txt +56 -9
- admin/class-advanced-cf7-db-admin.php +106 -2
- admin/js/advanced-cf7-db-admin.js +192 -1
- advanced-cf7-db.php +2 -2
- includes/class-advanced-cf7-db.php +4 -0
- includes/vsz-cf7-db-function.php +438 -407
README.txt
CHANGED
@@ -2,8 +2,8 @@
|
|
2 |
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: 4.9.
|
6 |
-
Stable tag: 1.4.
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
@@ -20,8 +20,8 @@ Attached files are stored in the /wp-content/uploads/advanced-cf7-upload directo
|
|
20 |
= Features =
|
21 |
* **Multisite compatible** to store individual site wise contact form data.
|
22 |
* Save Contact Form 7 form submitted data to the database.
|
|
|
23 |
* Display **all** created contact form 7 form list.
|
24 |
-
* Select Form name to see the entries.
|
25 |
* Keyword search for all the entries of selected form.
|
26 |
* **Date range filter** to filter specific date related entries easily.
|
27 |
* **Export all**, or only searched, filtered results with selected fields.
|
@@ -36,15 +36,23 @@ Attached files are stored in the /wp-content/uploads/advanced-cf7-upload directo
|
|
36 |
* Easy to update each field label name.
|
37 |
* Easy to setup **import functionality.**
|
38 |
* Facility to import form related entries from CSV file.
|
|
|
|
|
39 |
|
40 |
-
|
41 |
-
|
|
|
42 |
|
43 |
-
|
44 |
-
1. Goto -> wp-content/themes/{active theme folder}/functions.php
|
45 |
-
2. Open the functions.php file and place the code **do_shortcode( '[cf7-db-display-ip]' );** at the end of the file.
|
46 |
|
47 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
We have also introduced new feature "Schedule Report". This add-on is specially for businesses that require daily, weekly or monthly reports for the data that are stored at **Advanced Contact form 7 DB**. **Schedule Report For Advanced CF7 DB** plugin will do the same and send the email as per schedule set(Daily, Monthly, Weekly or Yearly) with report attachment.
|
49 |
|
50 |
You can download the plugin from <a target="_blank" href="https://codecanyon.net/item/schedule-report-for-advanced-cf7-db/21560647?s_rank=8">here</a>
|
@@ -57,6 +65,23 @@ You can download the plugin from <a target="_blank" href="https://codecanyon.net
|
|
57 |
* You can manage the email content by defining TO, FROM and email body content for each scheduling event.
|
58 |
* The added schedule event will be added to WordPress cron schedule and accordingly will be fire at the scheduled time.
|
59 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
|
61 |
**Need Support?** <mehul@vsourz.com>
|
62 |
|
@@ -109,6 +134,23 @@ Restriction is simple, just code **do_shortcode( '[cf7-db-display-ip]' );** to b
|
|
109 |
**For Multisite** it should be **do_shortcode( '[cf7-db-display-ip site_id="(your-site-id)"]' );**
|
110 |
- You need to add different shortcode for each site with specific siteId. If you need to restrict for all the sites then just place the shortcode without the parameter.
|
111 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
112 |
== Screenshots ==
|
113 |
|
114 |
1. Display form related records.
|
@@ -120,6 +162,11 @@ Restriction is simple, just code **do_shortcode( '[cf7-db-display-ip]' );** to b
|
|
120 |
|
121 |
== Changelog ==
|
122 |
|
|
|
|
|
|
|
|
|
|
|
123 |
= 1.4.3 =
|
124 |
* Fixed issue related to export records in PDF.
|
125 |
* Multisite support for IP restrict.
|
2 |
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: 4.9.8
|
6 |
+
Stable tag: 1.4.4
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
20 |
= Features =
|
21 |
* **Multisite compatible** to store individual site wise contact form data.
|
22 |
* Save Contact Form 7 form submitted data to the database.
|
23 |
+
* Easy to update/edit enquiry data.
|
24 |
* Display **all** created contact form 7 form list.
|
|
|
25 |
* Keyword search for all the entries of selected form.
|
26 |
* **Date range filter** to filter specific date related entries easily.
|
27 |
* **Export all**, or only searched, filtered results with selected fields.
|
36 |
* Easy to update each field label name.
|
37 |
* Easy to setup **import functionality.**
|
38 |
* Facility to import form related entries from CSV file.
|
39 |
+
* Provided filters for excluding particular contact form entry to CF7 DB.
|
40 |
+
* Provided filter to add,modify,remove CF7 fields and data before submitting to CF7 DB.
|
41 |
|
42 |
+
== Commercial Features ==
|
43 |
+
**1. Advanced CF7 DB - GDPR compliant**
|
44 |
+
Advanced CF7 DB – GDPR compliant plugin assists website and web-shop owners to comply with European privacy regulations known as GDPR. Advanced CF7 DB – GDPR compliant is an add-on of Advanced Cf7 DB, based on GDPR rules to Export or Erase user’s personal data stored with advanced cf7 DB. For more details you can check the below download link.
|
45 |
|
46 |
+
You can download the plugin from <a target="_blank" href="https://codecanyon.net/item/advanced-cf7-db-gdpr-compliant/22386060">here</a>
|
|
|
|
|
47 |
|
48 |
+
= Advanced CF7 DB - GDPR compliant Plugin Features =
|
49 |
+
* Compatible with the latest WordPress version 4.9.6 and later for GDPR compliances. Meets with the new regulations for the data to be handled.
|
50 |
+
* Individual CF7 form wise settings to show the personal data on user’s request.
|
51 |
+
* Erase only the CF7 form personal data, that are required.
|
52 |
+
* Site owners can export a ZIP file containing a user’s personal data, including data collected by Advanced CF7 DB plugin.
|
53 |
+
* Site owners can erase a user’s personal data, including data collected by Advanced CF7 DB plugin.
|
54 |
+
|
55 |
+
**2. Schedule Report**
|
56 |
We have also introduced new feature "Schedule Report". This add-on is specially for businesses that require daily, weekly or monthly reports for the data that are stored at **Advanced Contact form 7 DB**. **Schedule Report For Advanced CF7 DB** plugin will do the same and send the email as per schedule set(Daily, Monthly, Weekly or Yearly) with report attachment.
|
57 |
|
58 |
You can download the plugin from <a target="_blank" href="https://codecanyon.net/item/schedule-report-for-advanced-cf7-db/21560647?s_rank=8">here</a>
|
65 |
* You can manage the email content by defining TO, FROM and email body content for each scheduling event.
|
66 |
* The added schedule event will be added to WordPress cron schedule and accordingly will be fire at the scheduled time.
|
67 |
|
68 |
+
**3. Advanced CF7 DB - User Access Manager**
|
69 |
+
Need to provide access to other users? Your, search ends now, this plugin provides access to individual users OR based on user Role and accordingly user can view or edit the contact form DB data. For more details you can check the below download link.
|
70 |
+
|
71 |
+
You can download the plugin from <a target="_blank" href="https://codecanyon.net/item/advanced-cf7-db-user-access-manager/22058788">here</a>
|
72 |
+
|
73 |
+
= Advanced CF7 DB - User Access Manager Plugin Features =
|
74 |
+
* Provide access of contact form 7 DB to View & Update data to individual users OR based on user Role.
|
75 |
+
* Provide access of Single/Multiple forms to single user.
|
76 |
+
|
77 |
+
|
78 |
+
== Plugin Customization ==
|
79 |
+
= Restrict IP address storage =
|
80 |
+
* Some of Countries have introduced a Law to don't store the user's IP addresses into the database, So we had given provision to Restrict IP address storage.
|
81 |
+
|
82 |
+
= How to Restrict IP address storage? =
|
83 |
+
1. Goto -> wp-content/themes/{active theme folder}/functions.php
|
84 |
+
2. Open the functions.php file and place the code **do_shortcode( '[cf7-db-display-ip]' );** at the end of the file.
|
85 |
|
86 |
**Need Support?** <mehul@vsourz.com>
|
87 |
|
134 |
**For Multisite** it should be **do_shortcode( '[cf7-db-display-ip site_id="(your-site-id)"]' );**
|
135 |
- You need to add different shortcode for each site with specific siteId. If you need to restrict for all the sites then just place the shortcode without the parameter.
|
136 |
|
137 |
+
= How to restrict the plugin from storing form entry to contact form DB? =
|
138 |
+
Restriction is simple, just following below steps :
|
139 |
+
- Goto -> wp-content/themes/{active theme folder}/functions.php
|
140 |
+
- Open the functions.php file and place below code at the end of the file.
|
141 |
+
add_filter('vsz_cf7_unwanted_form_data_submission','vsz_restrict_form_data_submission');
|
142 |
+
function vsz_restrict_form_data_submission($contact_form_ids){
|
143 |
+
$contact_form_ids[] = {your-contact-form-id};
|
144 |
+
return $contact_form_ids;
|
145 |
+
}
|
146 |
+
**For multiple forms**
|
147 |
+
add_filter('vsz_cf7_unwanted_form_data_submission','vsz_restrict_form_data_submission');
|
148 |
+
function vsz_restrict_form_data_submission($contact_form_ids){
|
149 |
+
$contact_form_ids[] = ['{your-contact-form-id}','{your-contact-form-id}'];
|
150 |
+
return $contact_form_ids;
|
151 |
+
}
|
152 |
+
|
153 |
+
|
154 |
== Screenshots ==
|
155 |
|
156 |
1. Display form related records.
|
162 |
|
163 |
== Changelog ==
|
164 |
|
165 |
+
= 1.4.4 =
|
166 |
+
* Fixed issue related to export records in PDF.
|
167 |
+
* Provided filter for excluding particular contact form entry to the database
|
168 |
+
* Provided filter to add, modify, remove CF7 fields and data before submitting to the database.
|
169 |
+
|
170 |
= 1.4.3 =
|
171 |
* Fixed issue related to export records in PDF.
|
172 |
* Multisite support for IP restrict.
|
admin/class-advanced-cf7-db-admin.php
CHANGED
@@ -196,7 +196,12 @@ class Advanced_Cf7_Db_Admin {
|
|
196 |
$obj_form = vsz_cf7_get_the_form_list($fid);
|
197 |
|
198 |
//get pre define form fields information
|
199 |
-
$
|
|
|
|
|
|
|
|
|
|
|
200 |
|
201 |
/**** This functionality Added because when field settings not define then
|
202 |
Fields display as per form design format*/
|
@@ -960,6 +965,103 @@ class Advanced_Cf7_Db_Admin {
|
|
960 |
$role->add_cap('cf7_db_form_view'.$post_id);
|
961 |
$role->add_cap('cf7_db_form_edit_'.$post_id);
|
962 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
963 |
}//close class
|
964 |
|
965 |
//Generate CSV file here
|
@@ -1005,6 +1107,7 @@ function vsz_cf7_export_to_excel($fid, $ids_export){
|
|
1005 |
|
1006 |
$fid = intval($fid);
|
1007 |
$fields = vsz_cf7_get_db_fields($fid);
|
|
|
1008 |
|
1009 |
//Get form id related contact form object
|
1010 |
$obj_form = vsz_cf7_get_the_form_list($fid);
|
@@ -1088,7 +1191,7 @@ function vsz_cf7_export_to_pdf($fid, $ids_export){
|
|
1088 |
// require_once(dirname(__FILE__).'/pdfgenerate/mypdf.class.php');
|
1089 |
|
1090 |
require_once(dirname(__FILE__).'/pdfgenerate/dompdf/autoload.inc.php');
|
1091 |
-
require_once(dirname(__FILE__).'/pdfgenerate/dompdf/load_font.php');
|
1092 |
|
1093 |
// $pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, false, 'UTF-8', false);
|
1094 |
|
@@ -1117,6 +1220,7 @@ function vsz_cf7_export_to_pdf($fid, $ids_export){
|
|
1117 |
width:100%;
|
1118 |
white-space: normal;
|
1119 |
word-wrap: break-word;
|
|
|
1120 |
}
|
1121 |
td{
|
1122 |
padding:5px;
|
196 |
$obj_form = vsz_cf7_get_the_form_list($fid);
|
197 |
|
198 |
//get pre define form fields information
|
199 |
+
if(isset($obj_form[0])){
|
200 |
+
$arr_form_tag = $obj_form[0]->scan_form_tags();
|
201 |
+
}
|
202 |
+
else{
|
203 |
+
$arr_form_tag = array();
|
204 |
+
}
|
205 |
|
206 |
/**** This functionality Added because when field settings not define then
|
207 |
Fields display as per form design format*/
|
965 |
$role->add_cap('cf7_db_form_view'.$post_id);
|
966 |
$role->add_cap('cf7_db_form_edit_'.$post_id);
|
967 |
}
|
968 |
+
|
969 |
+
// Function to upload file from edit file popup
|
970 |
+
function vsz_acf7_db_edit_scr_file_upload(){
|
971 |
+
|
972 |
+
if(!isset($_POST["fid"]) || empty($_POST["fid"])){
|
973 |
+
print 'error';
|
974 |
+
exit;
|
975 |
+
}
|
976 |
+
if(!isset($_POST["rid"]) || empty($_POST["rid"])){
|
977 |
+
print 'error';
|
978 |
+
exit;
|
979 |
+
}
|
980 |
+
if(!isset($_POST["field"]) || empty($_POST["field"])){
|
981 |
+
print 'error';
|
982 |
+
exit;
|
983 |
+
}
|
984 |
+
|
985 |
+
global $wpdb;
|
986 |
+
$fid = $_POST["fid"];
|
987 |
+
$rid = $_POST["rid"];
|
988 |
+
$field = $_POST["field"];
|
989 |
+
|
990 |
+
$upload_dir = wp_upload_dir();
|
991 |
+
$acf7db_upload_folder = VSZ_CF7_UPLOAD_FOLDER;
|
992 |
+
$temp_dir_upload = $upload_dir['basedir'].'/'.$acf7db_upload_folder;
|
993 |
+
wp_mkdir_p($temp_dir_upload);
|
994 |
+
|
995 |
+
if(is_array($_FILES) && !empty($_FILES)){
|
996 |
+
$maxsize = 8000000;
|
997 |
+
if(($_FILES['image']['size'] >= $maxsize)) {
|
998 |
+
echo 'invalid_size';
|
999 |
+
exit;
|
1000 |
+
}
|
1001 |
+
$filename = sanitize_text_field($_FILES["image"]["name"]);
|
1002 |
+
$file_basename = substr($filename, 0, strripos($filename, '.')); // get file name
|
1003 |
+
$file_ext = substr($filename, strripos($filename, '.')); // get file extention
|
1004 |
+
//unique file name
|
1005 |
+
$newfilename = wp_unique_filename($temp_dir_upload, $file_basename.$file_ext);
|
1006 |
+
|
1007 |
+
if(move_uploaded_file($_FILES["image"]["tmp_name"], $temp_dir_upload. '/' .$newfilename)){
|
1008 |
+
$file_url = $upload_dir['baseurl'] . '/' . $acf7db_upload_folder.'/'.$newfilename;
|
1009 |
+
|
1010 |
+
$res = $wpdb->update(VSZ_CF7_DATA_ENTRY_TABLE_NAME, array("value" => $file_url), array("data_id" => $rid, "cf7_id" => $fid, "name" => $field));
|
1011 |
+
if($res !== false){
|
1012 |
+
echo "$newfilename~~@@~~&&~~$file_url";
|
1013 |
+
wp_die();
|
1014 |
+
}
|
1015 |
+
else{
|
1016 |
+
echo "n";
|
1017 |
+
wp_die();
|
1018 |
+
}
|
1019 |
+
}
|
1020 |
+
}
|
1021 |
+
wp_die();
|
1022 |
+
}
|
1023 |
+
|
1024 |
+
// Function to delete file from edit file popup
|
1025 |
+
function vsz_acf7_db_edit_scr_file_delete(){
|
1026 |
+
|
1027 |
+
if(!isset($_POST["fid"]) || empty($_POST["fid"])){
|
1028 |
+
print 'error';
|
1029 |
+
exit;
|
1030 |
+
}
|
1031 |
+
if(!isset($_POST["rid"]) || empty($_POST["rid"])){
|
1032 |
+
print 'error';
|
1033 |
+
exit;
|
1034 |
+
}
|
1035 |
+
if(!isset($_POST["field"]) || empty($_POST["field"])){
|
1036 |
+
print 'error';
|
1037 |
+
exit;
|
1038 |
+
}
|
1039 |
+
if(!isset($_POST["val"]) || empty($_POST["val"])){
|
1040 |
+
print 'error';
|
1041 |
+
exit;
|
1042 |
+
}
|
1043 |
+
|
1044 |
+
$fid = $_POST["fid"];
|
1045 |
+
$rid = $_POST["rid"];
|
1046 |
+
$field = $_POST["field"];
|
1047 |
+
$val = $_POST["val"];
|
1048 |
+
global $wpdb;
|
1049 |
+
|
1050 |
+
$res = $wpdb->update(VSZ_CF7_DATA_ENTRY_TABLE_NAME, array("value" => ""), array("data_id" => $rid, "cf7_id" => $fid, "name" => $field));
|
1051 |
+
if($res !== false){
|
1052 |
+
$upload_dir = wp_upload_dir();
|
1053 |
+
$dir_upload = $upload_dir['basedir'] .'/' .VSZ_CF7_UPLOAD_FOLDER;
|
1054 |
+
|
1055 |
+
unlink($dir_upload.'/'.$val);
|
1056 |
+
echo "y";
|
1057 |
+
wp_die();
|
1058 |
+
}
|
1059 |
+
else{
|
1060 |
+
echo "n";
|
1061 |
+
wp_die();
|
1062 |
+
}
|
1063 |
+
}
|
1064 |
+
|
1065 |
}//close class
|
1066 |
|
1067 |
//Generate CSV file here
|
1107 |
|
1108 |
$fid = intval($fid);
|
1109 |
$fields = vsz_cf7_get_db_fields($fid);
|
1110 |
+
$fields1 = vsz_field_type_info($fid);
|
1111 |
|
1112 |
//Get form id related contact form object
|
1113 |
$obj_form = vsz_cf7_get_the_form_list($fid);
|
1191 |
// require_once(dirname(__FILE__).'/pdfgenerate/mypdf.class.php');
|
1192 |
|
1193 |
require_once(dirname(__FILE__).'/pdfgenerate/dompdf/autoload.inc.php');
|
1194 |
+
//require_once(dirname(__FILE__).'/pdfgenerate/dompdf/load_font.php');
|
1195 |
|
1196 |
// $pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, false, 'UTF-8', false);
|
1197 |
|
1220 |
width:100%;
|
1221 |
white-space: normal;
|
1222 |
word-wrap: break-word;
|
1223 |
+
font-family: DroidSansFallback;
|
1224 |
}
|
1225 |
td{
|
1226 |
padding:5px;
|
admin/js/advanced-cf7-db-admin.js
CHANGED
@@ -198,6 +198,9 @@ jQuery(document).ready(function($) {
|
|
198 |
//Remove previous define anchor tag in edit form
|
199 |
if(jQuery('form#cf7d-modal-form-edit-value input[class^="field-'+fieldname+'"]').parent().find('a')){
|
200 |
jQuery('form#cf7d-modal-form-edit-value input[class^="field-'+fieldname+'"]').parent().find('a').remove();
|
|
|
|
|
|
|
201 |
}
|
202 |
jQuery('form#cf7d-modal-form-edit-value input[class^="field-'+fieldname+'"]').attr('value', 'Loading...');
|
203 |
}
|
@@ -250,10 +253,16 @@ jQuery(document).ready(function($) {
|
|
250 |
//Set file field related functionality here
|
251 |
else if(arr_field_type[index]['basetype'] == 'file'){
|
252 |
if(el){
|
253 |
-
var filename = el.split('/').pop()
|
|
|
254 |
jQuery('form#cf7d-modal-form-edit-value .field-' + index).attr('value', filename);
|
255 |
jQuery('form#cf7d-modal-form-edit-value .field-' + index).css("border","");
|
256 |
jQuery('form#cf7d-modal-form-edit-value .field-' + index).parent().append('<a class="margin_left" href="'+el+'" target="_blank" download >Download</a>');
|
|
|
|
|
|
|
|
|
|
|
257 |
}
|
258 |
}
|
259 |
//Check field type is text then execute this code
|
@@ -347,6 +356,188 @@ function validateEmail(email) {
|
|
347 |
return expr.test(email);
|
348 |
};
|
349 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
350 |
|
351 |
/**************** Check fields key related match key value empty or not *************************/
|
352 |
jQuery(document).ready(function() {
|
198 |
//Remove previous define anchor tag in edit form
|
199 |
if(jQuery('form#cf7d-modal-form-edit-value input[class^="field-'+fieldname+'"]').parent().find('a')){
|
200 |
jQuery('form#cf7d-modal-form-edit-value input[class^="field-'+fieldname+'"]').parent().find('a').remove();
|
201 |
+
jQuery('form#cf7d-modal-form-edit-value input[class^="field-'+fieldname+'"]').parent().find('.vsz_cf7_db_file_edit').remove();
|
202 |
+
jQuery('form#cf7d-modal-form-edit-value input[class^="field-'+fieldname+'"]').parent().find('.edit-field-file-val').remove();
|
203 |
+
jQuery('form#cf7d-modal-form-edit-value input[class^="field-'+fieldname+'"]').parent().find('span.margin_left').remove();
|
204 |
}
|
205 |
jQuery('form#cf7d-modal-form-edit-value input[class^="field-'+fieldname+'"]').attr('value', 'Loading...');
|
206 |
}
|
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();
|
257 |
+
// var filename = el;
|
258 |
jQuery('form#cf7d-modal-form-edit-value .field-' + index).attr('value', filename);
|
259 |
jQuery('form#cf7d-modal-form-edit-value .field-' + index).css("border","");
|
260 |
jQuery('form#cf7d-modal-form-edit-value .field-' + index).parent().append('<a class="margin_left" href="'+el+'" target="_blank" download >Download</a>');
|
261 |
+
jQuery('form#cf7d-modal-form-edit-value .field-' + index).parent().append('<a value="Change" class="vsz_cf7_db_file_edit" style="margin-left: 10px;" href="javascript:void(0);" >Remove</a>');
|
262 |
+
add_remove_file(index, filename);
|
263 |
+
}
|
264 |
+
else{
|
265 |
+
add_remove_file(index, "");
|
266 |
}
|
267 |
}
|
268 |
//Check field type is text then execute this code
|
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',
|
382 |
+
data : fd,
|
383 |
+
processData: false,
|
384 |
+
contentType: false,
|
385 |
+
beforeSend: function() {
|
386 |
+
document.getElementById('overlayLoader').style.display = "block";
|
387 |
+
},
|
388 |
+
success: function(data) {
|
389 |
+
jQuery('form#cf7d-modal-form-edit-value .field-' + index).parent().prepend('<input type="file" name="field['+index+']" class="field-'+index+'-val edit-field-file-val" />');
|
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',
|
416 |
+
data : fd,
|
417 |
+
processData: false,
|
418 |
+
contentType: false,
|
419 |
+
beforeSend: function() {
|
420 |
+
document.getElementById('overlayLoader').style.display = "block";
|
421 |
+
},
|
422 |
+
|
423 |
+
success: function(data) {
|
424 |
+
if(data != "invalid_size"){
|
425 |
+
dataArr = data.split("~~@@~~&&~~");
|
426 |
+
|
427 |
+
var filename = dataArr[0];
|
428 |
+
var el = dataArr[1];
|
429 |
+
|
430 |
+
jQuery('form#cf7d-modal-form-edit-value .field-' + index).attr('value', filename);
|
431 |
+
jQuery('form#cf7d-modal-form-edit-value .field-' + index).css("border","");
|
432 |
+
jQuery('form#cf7d-modal-form-edit-value .field-' + index).parent().append('<a class="margin_left" href="'+el+'" target="_blank" download >Download</a>');
|
433 |
+
jQuery('form#cf7d-modal-form-edit-value .field-' + index).parent().append('<a value="Change" class="vsz_cf7_db_file_edit" style="margin-left: 10px;" href="javascript:void(0);" >Remove</a>');
|
434 |
+
jQuery('form#cf7d-modal-form-edit-value .field-' + index).show();
|
435 |
+
jQuery('form#cf7d-modal-form-edit-value .field-' + index).parent().find('.field-'+index+'-val').remove();
|
436 |
+
jQuery('form#cf7d-modal-form-edit-value .field-' + index).parent().find('span.margin_left').remove();
|
437 |
+
|
438 |
+
// Calling function which will handle the removal and new upload of the files
|
439 |
+
add_remove_file(index,filename);
|
440 |
+
}
|
441 |
+
else{
|
442 |
+
alert("Maximum file size allowed is 7.60 MB.");
|
443 |
+
}
|
444 |
+
|
445 |
+
document.getElementById('overlayLoader').style.display = "none";
|
446 |
+
},
|
447 |
+
|
448 |
+
error: function(data) {
|
449 |
+
console.log(data);
|
450 |
+
document.getElementById('overlayLoader').style.display = "none";
|
451 |
+
alert("Sorry file was not uploaded.");
|
452 |
+
return false;
|
453 |
+
},
|
454 |
+
});
|
455 |
+
}
|
456 |
+
});
|
457 |
+
},
|
458 |
+
error: function(data) {
|
459 |
+
console.log(data);
|
460 |
+
document.getElementById('overlayLoader').style.display = "none";
|
461 |
+
alert("Sorry file was not removed.");
|
462 |
+
return false;
|
463 |
+
},
|
464 |
+
});
|
465 |
+
|
466 |
+
}
|
467 |
+
});
|
468 |
+
});
|
469 |
+
}
|
470 |
+
else{
|
471 |
+
jQuery('form#cf7d-modal-form-edit-value .field-' + index).parent().prepend('<input type="file" name="field['+index+']" class="field-'+index+'-val edit-field-file-val" />');
|
472 |
+
jQuery('form#cf7d-modal-form-edit-value .field-' + index).parent().find('a').remove();
|
473 |
+
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>');
|
474 |
+
jQuery('form#cf7d-modal-form-edit-value .field-' + index).hide();
|
475 |
+
|
476 |
+
document.getElementById('overlayLoader').style.display = "none";
|
477 |
+
|
478 |
+
jQuery(".field-"+index+"-val").change(function(){
|
479 |
+
var thisdata = jQuery(this);
|
480 |
+
var fileName = jQuery(thisdata).val();
|
481 |
+
var checkvalidate = 1;
|
482 |
+
|
483 |
+
if(fileName != "" && fileName != undefined){
|
484 |
+
var fd = new FormData();
|
485 |
+
var fid = jQuery("input[name='fid']").val();
|
486 |
+
var rid = jQuery("input[name='rid']").val();
|
487 |
+
var field = index;
|
488 |
+
|
489 |
+
fd.append( "image", jQuery(thisdata)[0].files[0]);
|
490 |
+
fd.append( "action", "acf7_db_edit_scr_file_upload");
|
491 |
+
fd.append( "fid", fid);
|
492 |
+
fd.append( "rid", rid);
|
493 |
+
fd.append( "field", field);
|
494 |
+
|
495 |
+
jQuery.ajax({
|
496 |
+
url: ajaxurl,
|
497 |
+
type: 'POST',
|
498 |
+
data : fd,
|
499 |
+
processData: false,
|
500 |
+
contentType: false,
|
501 |
+
beforeSend: function() {
|
502 |
+
document.getElementById('overlayLoader').style.display = "block";
|
503 |
+
},
|
504 |
+
|
505 |
+
success: function(data) {
|
506 |
+
if(data != "invalid_size"){
|
507 |
+
dataArr = data.split("~~@@~~&&~~");
|
508 |
+
|
509 |
+
var filename = dataArr[0];
|
510 |
+
var el = dataArr[1];
|
511 |
+
|
512 |
+
jQuery('form#cf7d-modal-form-edit-value .field-' + index).attr('value', filename);
|
513 |
+
jQuery('form#cf7d-modal-form-edit-value .field-' + index).css("border","");
|
514 |
+
jQuery('form#cf7d-modal-form-edit-value .field-' + index).parent().append('<a class="margin_left" href="'+el+'" target="_blank" download >Download</a>');
|
515 |
+
jQuery('form#cf7d-modal-form-edit-value .field-' + index).parent().append('<a value="Change" class="vsz_cf7_db_file_edit" style="margin-left: 10px;" href="javascript:void(0);" >Remove</a>');
|
516 |
+
jQuery('form#cf7d-modal-form-edit-value .field-' + index).show();
|
517 |
+
jQuery('form#cf7d-modal-form-edit-value .field-' + index).parent().find('.field-'+index+'-val').remove();
|
518 |
+
jQuery('form#cf7d-modal-form-edit-value .field-' + index).parent().find('span.margin_left').remove();
|
519 |
+
|
520 |
+
// Calling function which will handle the removal and new upload of the files
|
521 |
+
add_remove_file(index,filename);
|
522 |
+
}
|
523 |
+
else{
|
524 |
+
alert("Maximum file size allowed is 7.60 MB.");
|
525 |
+
}
|
526 |
+
|
527 |
+
document.getElementById('overlayLoader').style.display = "none";
|
528 |
+
},
|
529 |
+
|
530 |
+
error: function(data) {
|
531 |
+
console.log(data);
|
532 |
+
document.getElementById('overlayLoader').style.display = "none";
|
533 |
+
alert("Sorry file was not uploaded.");
|
534 |
+
return false;
|
535 |
+
},
|
536 |
+
});
|
537 |
+
}
|
538 |
+
});
|
539 |
+
}
|
540 |
+
}
|
541 |
|
542 |
/**************** Check fields key related match key value empty or not *************************/
|
543 |
jQuery(document).ready(function() {
|
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.4.
|
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.4.
|
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.4.4
|
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.4.4';
|
27 |
/**
|
28 |
* Defining all the table names and setting their prefix here
|
29 |
*/
|
includes/class-advanced-cf7-db.php
CHANGED
@@ -210,7 +210,11 @@ class Advanced_Cf7_Db {
|
|
210 |
// Provide custom capability
|
211 |
$this->loader->add_action('save_post',$plugin_admin,'vsz_cf7_create_role_for_contact_form');
|
212 |
|
|
|
|
|
213 |
|
|
|
|
|
214 |
}
|
215 |
|
216 |
/**
|
210 |
// Provide custom capability
|
211 |
$this->loader->add_action('save_post',$plugin_admin,'vsz_cf7_create_role_for_contact_form');
|
212 |
|
213 |
+
// Edit Popup file upload
|
214 |
+
$this->loader->add_action('wp_ajax_acf7_db_edit_scr_file_upload',$plugin_admin,'vsz_acf7_db_edit_scr_file_upload');
|
215 |
|
216 |
+
// Edit Popup file delete
|
217 |
+
$this->loader->add_action('wp_ajax_acf7_db_edit_scr_file_delete',$plugin_admin,'vsz_acf7_db_edit_scr_file_delete');
|
218 |
}
|
219 |
|
220 |
/**
|
includes/vsz-cf7-db-function.php
CHANGED
@@ -1,408 +1,439 @@
|
|
1 |
-
<?php
|
2 |
-
// Exit if accessed directly
|
3 |
-
if ( !defined( 'ABSPATH' ) ){
|
4 |
-
die('Un-authorized access!');
|
5 |
-
}
|
6 |
-
|
7 |
-
|
8 |
-
//Define contact form action which is call before mail is trigger
|
9 |
-
add_action('wpcf7_before_send_mail','vsz_cf7_before_send_email');
|
10 |
-
//Call this function when mail is trigger then get all form fields related information
|
11 |
-
function vsz_cf7_before_send_email($contact_form){
|
12 |
-
global $wpdb;
|
13 |
-
|
14 |
-
//Define this action for customize form data before insert in DB
|
15 |
-
do_action('vsz_cf7_before_insert_db', $contact_form);
|
16 |
-
|
17 |
-
//Get submitted contact form id
|
18 |
-
$cf7_id = $contact_form->id();
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
$
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
//
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
function
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
$
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
}
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
$label = esc_html($v);
|
305 |
-
}
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
$
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
$
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
408 |
}
|
1 |
+
<?php
|
2 |
+
// Exit if accessed directly
|
3 |
+
if ( !defined( 'ABSPATH' ) ){
|
4 |
+
die('Un-authorized access!');
|
5 |
+
}
|
6 |
+
|
7 |
+
|
8 |
+
//Define contact form action which is call before mail is trigger
|
9 |
+
add_action('wpcf7_before_send_mail','vsz_cf7_before_send_email');
|
10 |
+
//Call this function when mail is trigger then get all form fields related information
|
11 |
+
function vsz_cf7_before_send_email($contact_form){
|
12 |
+
global $wpdb;
|
13 |
+
$contact_form_ids = array();
|
14 |
+
//Define this action for customize form data before insert in DB
|
15 |
+
do_action('vsz_cf7_before_insert_db', $contact_form);
|
16 |
+
|
17 |
+
//Get submitted contact form id
|
18 |
+
$cf7_id = $contact_form->id();
|
19 |
+
|
20 |
+
/*
|
21 |
+
* Restriction of the whole form submission to the database
|
22 |
+
* Filter provided to get all the un-necessary form data to be submitted
|
23 |
+
*/
|
24 |
+
|
25 |
+
$arr_contact_form_ids = (array) apply_filters('vsz_cf7_unwanted_form_data_submission', $contact_form_ids);
|
26 |
+
|
27 |
+
if(!empty($arr_contact_form_ids) && is_array($arr_contact_form_ids) && in_array($cf7_id, $arr_contact_form_ids)) return;
|
28 |
+
|
29 |
+
$contact_form = vsz_cf7_get_posted_data($contact_form);
|
30 |
+
|
31 |
+
//for database installion
|
32 |
+
$contact_form = vsz_cf7_add_extra_fields($contact_form);
|
33 |
+
|
34 |
+
$contact_form = apply_filters('vsz_cf7_modify_form_before_insert_data', $contact_form);
|
35 |
+
|
36 |
+
//Type's $contact_form->posted_data is array
|
37 |
+
// Define filter for customize posted data
|
38 |
+
/* Below filter will be provided to the Users to modify the data
|
39 |
+
* Below is the process that can be performed
|
40 |
+
* 1) Add new data to the CF7 Form
|
41 |
+
* 2) Can modify the existing form submitted data
|
42 |
+
* 3) Can unset or remove the existing form data of CF7
|
43 |
+
*
|
44 |
+
*/
|
45 |
+
|
46 |
+
$contact_form->posted_data = apply_filters('vsz_cf7_posted_data', $contact_form->posted_data);
|
47 |
+
|
48 |
+
//Insert current form submission time in database
|
49 |
+
$time = date('Y-m-d H:i:s');
|
50 |
+
$wpdb->query($wpdb->prepare('INSERT INTO '.VSZ_CF7_DATA_TABLE_NAME.'(`created`) VALUES (%s)', $time));
|
51 |
+
//Get last inserted id
|
52 |
+
$data_id = $wpdb->insert_id;
|
53 |
+
|
54 |
+
//Insert form values in custom data entry table
|
55 |
+
if(!empty($cf7_id) && !empty($data_id)){
|
56 |
+
//Get not inserted fields value list
|
57 |
+
$cf7d_no_save_fields = vsz_cf7_no_save_fields();
|
58 |
+
foreach ($contact_form->posted_data as $k => $v) {
|
59 |
+
//Check not inserted fields name in array or not
|
60 |
+
if(in_array($k, $cf7d_no_save_fields)) {
|
61 |
+
continue;
|
62 |
+
}
|
63 |
+
else{
|
64 |
+
//If value is check box and radio button value then creaye single string
|
65 |
+
if(is_array($v)){
|
66 |
+
$v = implode("\n", $v);
|
67 |
+
}
|
68 |
+
$k = htmlspecialchars($k);
|
69 |
+
$v = htmlspecialchars($v);
|
70 |
+
$wpdb->query($wpdb->prepare('INSERT INTO '.VSZ_CF7_DATA_ENTRY_TABLE_NAME.'(`cf7_id`, `data_id`, `name`, `value`) VALUES (%d,%d,%s,%s)', $cf7_id, $data_id, $k, $v));
|
71 |
+
}
|
72 |
+
}
|
73 |
+
//Add action for customize process after insert value in data base
|
74 |
+
do_action('vsz_cf7_after_insert_db', $contact_form, $cf7_id, $data_id);
|
75 |
+
}
|
76 |
+
|
77 |
+
}
|
78 |
+
|
79 |
+
/*
|
80 |
+
* Support CF7 functions
|
81 |
+
*/
|
82 |
+
function vsz_cf7_get_posted_data($cf7){
|
83 |
+
|
84 |
+
if (!isset($cf7->posted_data) && class_exists('WPCF7_Submission')) {
|
85 |
+
// Contact Form 7 version 3.9 removed $cf7->posted_data and now
|
86 |
+
// we have to retrieve it from an API
|
87 |
+
$submission = WPCF7_Submission::get_instance();
|
88 |
+
if ($submission){
|
89 |
+
$data = array();
|
90 |
+
$data['title'] = $cf7->title();
|
91 |
+
$data['posted_data'] = $submission->get_posted_data();
|
92 |
+
$data['uploaded_files'] = $submission->uploaded_files();
|
93 |
+
$data['WPCF7_ContactForm'] = $cf7;
|
94 |
+
$cf7 = (object) $data;
|
95 |
+
}
|
96 |
+
}
|
97 |
+
return $cf7;
|
98 |
+
}
|
99 |
+
|
100 |
+
/*
|
101 |
+
* Add additional value with form data
|
102 |
+
*/
|
103 |
+
function vsz_cf7_add_extra_fields($cf7){
|
104 |
+
|
105 |
+
$submission = WPCF7_Submission::get_instance();
|
106 |
+
|
107 |
+
//Get time stamp value in valid date format
|
108 |
+
$cf7->posted_data['submit_time'] = date_i18n('Y-m-d H:i:s', $submission->get_meta('timestamp'));
|
109 |
+
|
110 |
+
if(!defined('vsz_cf7_display_ip')){
|
111 |
+
//Get submitted ip address
|
112 |
+
$cf7->posted_data['submit_ip'] = (isset($_SERVER['X_FORWARDED_FOR'])) ? $_SERVER['X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR'];
|
113 |
+
}
|
114 |
+
return $cf7;
|
115 |
+
}
|
116 |
+
|
117 |
+
//save files uploaded by user and modify data before inserting to database
|
118 |
+
add_filter('vsz_cf7_modify_form_before_insert_data', 'vsz_cf7_modify_form_before_insert_in_cf7_vdata_entry');
|
119 |
+
if (!function_exists('vsz_cf7_modify_form_before_insert_in_cf7_vdata_entry')) {
|
120 |
+
function vsz_cf7_modify_form_before_insert_in_cf7_vdata_entry($cf7){
|
121 |
+
//if it has at lest 1 file uploaded
|
122 |
+
if (count($cf7->uploaded_files) > 0) {
|
123 |
+
//Get upload dir URL
|
124 |
+
$upload_dir = wp_upload_dir();
|
125 |
+
//Create custom upload folder
|
126 |
+
$cf7d_upload_folder = VSZ_CF7_UPLOAD_FOLDER;
|
127 |
+
$dir_upload = $upload_dir['basedir'] . '/' . $cf7d_upload_folder;
|
128 |
+
wp_mkdir_p($dir_upload);
|
129 |
+
//Get all uploaded files information
|
130 |
+
foreach ($cf7->uploaded_files as $k => $v) {
|
131 |
+
//Get file name
|
132 |
+
$file_name = basename($v);
|
133 |
+
//Create unique file name
|
134 |
+
$file_name = wp_unique_filename($dir_upload, $file_name);
|
135 |
+
//Setup filoe path
|
136 |
+
$dst_file = $dir_upload . '/' . $file_name;
|
137 |
+
//Copy file information in destination variable
|
138 |
+
if (@copy($v, $dst_file)){
|
139 |
+
//Setup customize file information in array
|
140 |
+
$cf7->posted_data[$k] = $upload_dir['baseurl'] . '/' . $cf7d_upload_folder . '/' . $file_name;
|
141 |
+
}
|
142 |
+
}//Close foreach
|
143 |
+
}//Close if
|
144 |
+
return $cf7;
|
145 |
+
}//Close function
|
146 |
+
}//Close if for check function exist or not
|
147 |
+
|
148 |
+
//Define function for which field value not insert in table
|
149 |
+
function vsz_cf7_no_save_fields(){
|
150 |
+
$cf7d_no_save_fields = array('_wpcf7', '_wpcf7_version', '_wpcf7_locale', '_wpcf7_unit_tag', '_wpcf7_is_ajax_call','_wpcf7_container_post');
|
151 |
+
//Add filter for customize values
|
152 |
+
return apply_filters('vsz_cf7_no_save_fields', $cf7d_no_save_fields);
|
153 |
+
}//Close function
|
154 |
+
|
155 |
+
//Get all contact form list here
|
156 |
+
function vsz_cf7_get_the_form_list($fid = ''){
|
157 |
+
|
158 |
+
//Get All form information
|
159 |
+
$forms = WPCF7_ContactForm::find();
|
160 |
+
$form = array();
|
161 |
+
//fetch each form information
|
162 |
+
|
163 |
+
foreach ($forms as $k => $v){
|
164 |
+
//Check if form id not empty then get specific form related information
|
165 |
+
if(!empty($fid)){
|
166 |
+
if($v->id() === $fid){
|
167 |
+
$form[] = $v;
|
168 |
+
return $form;
|
169 |
+
}
|
170 |
+
}
|
171 |
+
else{
|
172 |
+
$form[] = $v;
|
173 |
+
}
|
174 |
+
}
|
175 |
+
// New function Added to sort the array by CF7 Name
|
176 |
+
usort($form, "cmp_sort_form_name");
|
177 |
+
|
178 |
+
return $form;
|
179 |
+
}//Close function
|
180 |
+
/*
|
181 |
+
* Sorting the contact forms to asc order by CF7 name
|
182 |
+
*/
|
183 |
+
function cmp_sort_form_name($a, $b)
|
184 |
+
{
|
185 |
+
//return $a->name > $b->name;
|
186 |
+
return strcmp($a->name(), $b->name());
|
187 |
+
|
188 |
+
}
|
189 |
+
|
190 |
+
|
191 |
+
|
192 |
+
/*
|
193 |
+
* $data: rows from database
|
194 |
+
* $fid: form id
|
195 |
+
*/
|
196 |
+
function vsz_cf7_sortdata($data){
|
197 |
+
$data_sorted = array();
|
198 |
+
//Set submitted id wise form information
|
199 |
+
foreach ($data as $k => $v) {
|
200 |
+
if(!isset($data_sorted[$v->data_id])){
|
201 |
+
$data_sorted[$v->data_id] = array();
|
202 |
+
}
|
203 |
+
$data_sorted[$v->data_id][$v->name] = apply_filters('cf7d_entry_value', trim(wp_unslash($v->value)), $v->name);
|
204 |
+
}
|
205 |
+
|
206 |
+
return $data_sorted;
|
207 |
+
}
|
208 |
+
|
209 |
+
//Get form id related fields information from DB
|
210 |
+
function vsz_cf7_get_db_fields($fid, $filter = true){
|
211 |
+
global $wpdb;
|
212 |
+
$fid = (int)$fid;
|
213 |
+
$sql = "SELECT `name` FROM `".VSZ_CF7_DATA_ENTRY_TABLE_NAME."` WHERE cf7_id = ".$fid." GROUP BY `name`";
|
214 |
+
$data = $wpdb->get_results($sql);
|
215 |
+
|
216 |
+
//Set each field value in array
|
217 |
+
$fields = array();
|
218 |
+
if(!empty($data)){
|
219 |
+
|
220 |
+
foreach ($data as $k => $v) {
|
221 |
+
if(defined('vsz_cf7_display_ip')){
|
222 |
+
if($v->name != 'submit_ip'){
|
223 |
+
$fields[$v->name] = htmlspecialchars_decode($v->name);
|
224 |
+
}
|
225 |
+
}
|
226 |
+
else{
|
227 |
+
$fields[$v->name] = htmlspecialchars_decode($v->name);
|
228 |
+
}
|
229 |
+
}
|
230 |
+
}
|
231 |
+
|
232 |
+
//Check if filter is true or not
|
233 |
+
if ($filter) {
|
234 |
+
//Get all fields information as per Setting screen
|
235 |
+
$fields = apply_filters('vsz_cf7_admin_fields', $fields, $fid);
|
236 |
+
}
|
237 |
+
|
238 |
+
return $fields;
|
239 |
+
}//Close function
|
240 |
+
|
241 |
+
//Add option value in specific select box request
|
242 |
+
if(!function_exists('vsz_cf7_arr_to_option')){
|
243 |
+
function vsz_cf7_arr_to_option($arr){
|
244 |
+
$html = '';
|
245 |
+
if(!empty($arr) && is_array($arr)){
|
246 |
+
foreach($arr as $k => $v) {
|
247 |
+
$html .= '<option value="'.esc_html($k).'">'.esc_html($v).'</option>';
|
248 |
+
}
|
249 |
+
}
|
250 |
+
return $html;
|
251 |
+
}
|
252 |
+
}
|
253 |
+
|
254 |
+
//get speicfic fields related information
|
255 |
+
function vsz_cf7_admin_get_field_name($field){
|
256 |
+
return esc_html($field);
|
257 |
+
}
|
258 |
+
|
259 |
+
//Get form id and specific entry related keys information
|
260 |
+
function get_entry_related_fields_info($fid,$entryId){
|
261 |
+
$fields = array();
|
262 |
+
if(!empty($fid) && !empty($entryId)){
|
263 |
+
|
264 |
+
global $wpdb;
|
265 |
+
$fid = intval($fid);
|
266 |
+
$entryId = intval($entryId);
|
267 |
+
|
268 |
+
$sql = "SELECT `name` FROM `".VSZ_CF7_DATA_ENTRY_TABLE_NAME."` WHERE `cf7_id` = ".$fid." AND `data_id` = ".$entryId." GROUP BY `name`";
|
269 |
+
$data = $wpdb->get_results($sql);
|
270 |
+
if(!empty($data)){
|
271 |
+
foreach ($data as $k => $v) {
|
272 |
+
$fields[$v->name] = htmlspecialchars_decode($v->name);
|
273 |
+
}
|
274 |
+
}
|
275 |
+
}
|
276 |
+
return $fields;
|
277 |
+
}
|
278 |
+
|
279 |
+
//Check current action
|
280 |
+
function vsz_cf7_current_action(){
|
281 |
+
|
282 |
+
$current_action = false;
|
283 |
+
if (isset($_POST['action']) && -1 != $_POST['action'] && isset($_POST['btn_apply'])) {
|
284 |
+
$current_action = sanitize_text_field($_POST['action']);
|
285 |
+
return apply_filters('vsz_cf7_get_current_action', $current_action);
|
286 |
+
}
|
287 |
+
|
288 |
+
if (isset($_POST['action2']) && -1 != $_POST['action2'] && isset($_POST['btn_apply2'])) {
|
289 |
+
$current_action = sanitize_text_field($_POST['action2']);
|
290 |
+
return apply_filters('vsz_cf7_get_current_action', $current_action);
|
291 |
+
}
|
292 |
+
$current_action = apply_filters('vsz_cf7_get_current_action', $current_action);
|
293 |
+
return false;
|
294 |
+
}
|
295 |
+
|
296 |
+
|
297 |
+
//Display field type related values here
|
298 |
+
function vsz_display_field_type_value($type,$arr_field_type,$k,$v){
|
299 |
+
$type = esc_html($type);
|
300 |
+
$k = esc_html($k);
|
301 |
+
if($type == 'checkbox'){
|
302 |
+
|
303 |
+
if(is_array($v)){
|
304 |
+
$label = esc_html($v['label']);
|
305 |
+
}
|
306 |
+
else{
|
307 |
+
$label = esc_html($v);
|
308 |
+
}
|
309 |
+
$loading = __('Loading...');
|
310 |
+
echo "<li class=\"clearfix\">
|
311 |
+
<span class=\"label\">".$label." (".$type.")</span>
|
312 |
+
<textarea name=\"field[".$k."]\" rows=\"3\" cols=\"20\" class=\"field-".$k."\" >".$loading."</textarea>
|
313 |
+
<span class=\"margin_left\">(Multiple entry start from new line)</span>
|
314 |
+
<div class=\"clear\"></div>
|
315 |
+
</li>";
|
316 |
+
}
|
317 |
+
else if($type == 'radio'){
|
318 |
+
|
319 |
+
if(is_array($v)){
|
320 |
+
$label = esc_html($v['label']);
|
321 |
+
}
|
322 |
+
else{
|
323 |
+
$label = esc_html($v);
|
324 |
+
}
|
325 |
+
$loading = __('Loading...');
|
326 |
+
echo "<li class=\"clearfix\">
|
327 |
+
<span class=\"label\">".$label." (".$type.")</span>
|
328 |
+
<textarea name=\"field[".$k."]\" rows=\"3\" cols=\"20\" class=\"field-".$k."\" >".$loading."</textarea><div class=\"clear\"></div></li>";
|
329 |
+
}
|
330 |
+
else if($type == 'select'){
|
331 |
+
if(is_array($v)){
|
332 |
+
$label = esc_html($v['label']);
|
333 |
+
}
|
334 |
+
else{
|
335 |
+
$label = esc_html($v);
|
336 |
+
}
|
337 |
+
$loading = __('Loading...');
|
338 |
+
echo "<li class=\"clearfix\">
|
339 |
+
<span class=\"label\">".$label." (".$type.")</span>
|
340 |
+
<textarea name=\"field[".$k."]\" rows=\"3\" cols=\"20\" class=\"field-".$k."\" >".$loading."</textarea><div class=\"clear\"></div></li>";
|
341 |
+
}
|
342 |
+
else if($type == 'textarea'){
|
343 |
+
if(is_array($v)){
|
344 |
+
$label = esc_html($v['label']);
|
345 |
+
}
|
346 |
+
else{
|
347 |
+
$label = esc_html($v);
|
348 |
+
}
|
349 |
+
$loading = __('Loading...');
|
350 |
+
echo "<li class=\"clearfix\">
|
351 |
+
<span class=\"label\">".$label."</span>
|
352 |
+
<textarea name=\"field[".$k."]\" rows=\"3\" cols=\"20\" class=\"field-".$k."\" >".$loading."</textarea><div class=\"clear\"></div></li>";
|
353 |
+
}
|
354 |
+
else if($type == 'file'){
|
355 |
+
if(is_array($v)){
|
356 |
+
$label = esc_html($v['label']);
|
357 |
+
}
|
358 |
+
else{
|
359 |
+
$label = esc_html($v);
|
360 |
+
}
|
361 |
+
$loading = __('Loading...');
|
362 |
+
$disable = 'readonly';
|
363 |
+
echo "<li class=\"clearfix\">
|
364 |
+
<span class=\"label\">".$label."</span>
|
365 |
+
<input class=\"field-".$k."\" type=\"text\" name=\"field[".$k."]\" value=\"".$loading."\" ".$disable." /><div class=\"clear\"></div></li>";
|
366 |
+
}else if($type == 'tel'){
|
367 |
+
|
368 |
+
if(is_array($v)){
|
369 |
+
$label = esc_html($v['label']);
|
370 |
+
}
|
371 |
+
else{
|
372 |
+
$label = esc_html($v);
|
373 |
+
}
|
374 |
+
$loading = __('Loading...');
|
375 |
+
echo "<li class=\"clearfix\">
|
376 |
+
<span class=\"label\">".$label."</span>
|
377 |
+
<input class=\"field-".$k."\" type=\"text\" name=\"field[".$k."]\" value=\"".$loading."\" /><div class=\"clear\"></div></li>";
|
378 |
+
}else if($type == 'dynamictext'|| $type == 'dynamichidden'|| $type == 'url' || $type == 'number' || $type == 'date' || $type == 'acceptance' || $type == 'quiz'){
|
379 |
+
if(is_array($v)){
|
380 |
+
$label = esc_html($v['label']);
|
381 |
+
}
|
382 |
+
else{
|
383 |
+
$label = esc_html($v);
|
384 |
+
}
|
385 |
+
$loading = __('Loading...');
|
386 |
+
echo "<li class=\"clearfix\">
|
387 |
+
<span class=\"label\">".$label."</span>
|
388 |
+
<input class=\"field-".$k."\" type=\"text\" name=\"field[".$k."]\" value=\"".$loading."\" /><div class=\"clear\"></div></li>";
|
389 |
+
}else{
|
390 |
+
if(is_array($v)){
|
391 |
+
$label = esc_html($v['label']);
|
392 |
+
}
|
393 |
+
else{
|
394 |
+
$label = esc_html($v);
|
395 |
+
}
|
396 |
+
$loading = __('Loading...');
|
397 |
+
echo "<li class=\"clearfix\">
|
398 |
+
<span class=\"label\">".$label."</span>
|
399 |
+
<textarea name=\"field[".$k."]\" rows=\"3\" cols=\"20\" class=\"field-".$k."\" >".$loading."</textarea><div class=\"clear\"></div></li>";
|
400 |
+
}
|
401 |
+
|
402 |
+
}
|
403 |
+
|
404 |
+
//Define sheet related date formates
|
405 |
+
function vsz_cf7_import_date_format_callback(){
|
406 |
+
|
407 |
+
$arr_dates = array('Y-m-d H:i:s P' => date('Y-m-d H:i:s P'),
|
408 |
+
'Y-m-d' => date('Y-m-d'),
|
409 |
+
'Y/m/d' => date('Y/m/d'),
|
410 |
+
'jS F, Y' => date('jS F, Y'),
|
411 |
+
'F j, Y' => date('F j, Y'),
|
412 |
+
'd/m/Y' => date('d/m/Y'),
|
413 |
+
'd-m-Y' => date('d-m-Y')
|
414 |
+
);
|
415 |
+
return $arr_dates;
|
416 |
+
}
|
417 |
+
|
418 |
+
//Get field name related type information
|
419 |
+
function vsz_field_type_info($fid){
|
420 |
+
|
421 |
+
if(empty($fid) || !intval($fid)) return ;
|
422 |
+
|
423 |
+
$fid = intval($fid);
|
424 |
+
$obj_form = vsz_cf7_get_the_form_list($fid);
|
425 |
+
//get pre define fields information
|
426 |
+
$arr_form_tag = $obj_form[0]->scan_form_tags();
|
427 |
+
$arr_field_type = array();
|
428 |
+
if(!empty($arr_form_tag)){
|
429 |
+
//Get all fields related information
|
430 |
+
foreach($arr_form_tag as $key => $arr_type){
|
431 |
+
//Check if tag type is submit then ignore tag info
|
432 |
+
if($arr_type['basetype'] == 'submit') continue;
|
433 |
+
//get field type information
|
434 |
+
$arr_field_type[$arr_type['name']] = $arr_type['basetype'];
|
435 |
+
}
|
436 |
+
}
|
437 |
+
|
438 |
+
return $arr_field_type;
|
439 |
}
|