Gravity PDF - Version 3.5.7

Version Description

  • Bug - Fixed issue where the PDF settings page was blank for some users
Download this release

Release Info

Developer Blue Liquid Designs
Plugin Icon 128x128 Gravity PDF
Version 3.5.7
Comparing to
See all releases

Code changes from version 3.5.6 to 3.5.7

.gitignore DELETED
@@ -1,5 +0,0 @@
1
- _notes
2
- _notes/*
3
- Thumbs.db
4
- default.po
5
- default.mo
 
 
 
 
 
README.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://www.gravityformspdfextended.com
4
  Tags: gravity, forms, pdf, automation, attachment
5
  Requires at least: 3.5
6
  Tested up to: 3.9
7
- Stable tag: 3.5.6
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -81,6 +81,9 @@ All FAQs can be [viewed on the Gravity Forms PDF Extended website](http://gravit
81
 
82
  == Changelog ==
83
 
 
 
 
84
  = 3.5.6 =
85
  * Bug - Fixed issue with last release that affected checks to see if Gravity Forms has submitting
86
  * Bug - Fixed fatal error with servers using PHP5.2 or lower
4
  Tags: gravity, forms, pdf, automation, attachment
5
  Requires at least: 3.5
6
  Tested up to: 3.9
7
+ Stable tag: 3.5.7
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
81
 
82
  == Changelog ==
83
 
84
+ = 3.5.7 =
85
+ * Bug - Fixed issue where the PDF settings page was blank for some users
86
+
87
  = 3.5.6 =
88
  * Bug - Fixed issue with last release that affected checks to see if Gravity Forms has submitting
89
  * Bug - Fixed fatal error with servers using PHP5.2 or lower
pdf.php CHANGED
@@ -4,7 +4,7 @@
4
  Plugin Name: Gravity Forms PDF Extended
5
  Plugin URI: http://www.gravityformspdfextended.com
6
  Description: Gravity Forms PDF Extended allows you to save/view/download a PDF from the front- and back-end, and automate PDF creation on form submission. Our Business Plus package also allows you to overlay field onto an existing PDF.
7
- Version: 3.5.6
8
  Author: Blue Liquid Designs
9
  Author URI: http://www.blueliquiddesigns.com.au
10
 
@@ -33,7 +33,7 @@ GNU General Public License for more details.
33
  /*
34
  * Define our constants
35
  */
36
- define('PDF_EXTENDED_VERSION', '3.5.6');
37
  define('GF_PDF_EXTENDED_SUPPORTED_VERSION', '1.7');
38
  define('GF_PDF_EXTENDED_WP_SUPPORTED_VERSION', '3.5');
39
  define('GF_PDF_EXTENDED_PHP_SUPPORTED_VERSION', '5');
@@ -123,7 +123,12 @@ class GFPDF_Core extends PDFGenerator
123
  * and ensure the plugin functions smoothly
124
  */
125
  add_action('admin_init', array('GFPDF_Core', 'fully_loaded_admin'), 9999); /* run later than usual to give our auto initialiser a chance to fire */
126
- add_action('after_switch_theme', array('GFPDF_InstallUpdater', 'gf_pdf_on_switch_theme'), 10, 2); /* listen for a theme chance and sync our PDF_EXTENDED_TEMPLATE folder */
 
 
 
 
 
127
 
128
  /*
129
  * Only load the plugin if the following requirements are met:
@@ -173,12 +178,7 @@ class GFPDF_Core extends PDFGenerator
173
  * Set up the PDF configuration and indexer
174
  * Accessed through $this->configuration and $this->index.
175
  */
176
- parent::__construct();
177
-
178
- /*
179
- * Run our scripts and add the settings page to the admin area
180
- */
181
- add_action('admin_init', array('GFPDF_Core', 'gfe_admin_init'), 9);
182
 
183
  /*
184
  * Add our main hooks
4
  Plugin Name: Gravity Forms PDF Extended
5
  Plugin URI: http://www.gravityformspdfextended.com
6
  Description: Gravity Forms PDF Extended allows you to save/view/download a PDF from the front- and back-end, and automate PDF creation on form submission. Our Business Plus package also allows you to overlay field onto an existing PDF.
7
+ Version: 3.5.7
8
  Author: Blue Liquid Designs
9
  Author URI: http://www.blueliquiddesigns.com.au
10
 
33
  /*
34
  * Define our constants
35
  */
36
+ define('PDF_EXTENDED_VERSION', '3.5.7');
37
  define('GF_PDF_EXTENDED_SUPPORTED_VERSION', '1.7');
38
  define('GF_PDF_EXTENDED_WP_SUPPORTED_VERSION', '3.5');
39
  define('GF_PDF_EXTENDED_PHP_SUPPORTED_VERSION', '5');
123
  * and ensure the plugin functions smoothly
124
  */
125
  add_action('admin_init', array('GFPDF_Core', 'fully_loaded_admin'), 9999); /* run later than usual to give our auto initialiser a chance to fire */
126
+ add_action('after_switch_theme', array('GFPDF_InstallUpdater', 'gf_pdf_on_switch_theme'), 10, 2); /* listen for a theme chance and sync our PDF_EXTENDED_TEMPLATE folder */
127
+
128
+ /*
129
+ * Run our scripts and add the settings page to the admin area
130
+ */
131
+ add_action('admin_init', array('GFPDF_Core', 'gfe_admin_init'), 9);
132
 
133
  /*
134
  * Only load the plugin if the following requirements are met:
178
  * Set up the PDF configuration and indexer
179
  * Accessed through $this->configuration and $this->index.
180
  */
181
+ parent::__construct();
 
 
 
 
 
182
 
183
  /*
184
  * Add our main hooks
resources/css/admin-styles.css CHANGED
@@ -57,6 +57,7 @@ font-size: 95%;
57
  color: #444;
58
  padding-top: 7px;
59
  display: block;
 
60
  }
61
 
62
  #support-request input, #support-request select {
57
  color: #444;
58
  padding-top: 7px;
59
  display: block;
60
+ clear: left;
61
  }
62
 
63
  #support-request input, #support-request select {
resources/css/admin-styles.min.css CHANGED
@@ -1 +1 @@
1
- #pdfextended-settings{margin-top:20px}#pdfextended-settings ol,#pdfextended-settings ul{margin-left:25px}#pdfextended-settings ul>li{list-style:disc}#pdfextended-settings ol>li{list-style:decimal}#pdfextended-settings ol li>ul,#pdfextended-settings ul li>ul{margin:5px 0 0 20px}#pdfextended-settings ul ul>li{list-style:circle}#pdfextended-settings ol ul>li{list-style:disc}#gform_tab_group #icon-gf_edit_forms{display:none}.detailed_pdf{clear:left;margin-bottom:3px}.detailed_pdf span{display:block;padding:2px 0 2px 2px}#support-request label{display:block;font-weight:bold}#pdf-system-status{overflow:hidden}#pdf-system-status p{clear:left}#pdf-system-status span.details,#support-request span.details{font-size:95%;color:#444;padding-top:7px;display:block}#support-request input,#support-request select{width:20em}#support-request input[type="submit"]{width:auto}#support-request textarea{width:65%;height:150px}#support-request input,#support-request textarea{padding:5px 4px}#support-request #support-request-button{padding:0 8px}#support-request .gfspinner{vertical-align:middle;margin-left:5px}#support-request textarea{border:1px solid #999;color:#444}#support-request :disabled,#support-request textarea:disabled{color:#CCC;border:1px solid #CCC}#support-request input.error,#support-request textarea.error,#support-request select.error{color:#d10b0b;border:1px solid #d10b0b}#support-request .icon-remove-sign{vertical-align:middle}.icon-spinner{font-size:18px;margin-left:5px}#support-request span.msg{margin-left:5px;color:#008000}#support-request span.error{margin-left:5px;color:#d10b0b}#pdfextended-settings #changelog h3{margin-top:20px}#pdfextended-settings div.notice{margin:5px 15px 2px;padding:0 .6em}#pdfextended-settings div.notice{background-color:#fff;border-left:4px solid #7ad03a;box-shadow:0 1px 1px 0 rgba(0,0,0,0.1)}.wrap #pdfextended-settings div.notice{margin:5px 0 15px;padding:1px 12px}div.notice p{margin:.5em 0;padding:2px}[class^="icon-"]:before,[class*=" icon-"]:before{display:inline-block;text-decoration:inherit;-webkit-font-smoothing:antialiased}[class^="icon-"],[class*=" icon-"]{background-image:none;background-position:0 0;background-repeat:repeat;display:inline;height:auto;line-height:normal;margin-top:0;vertical-align:baseline;width:auto;-webkit-font-smoothing:antialiased}[class^="icon-"],[class*=" icon-"]{font-family:"dashicons";font-style:normal;font-weight:normal;text-decoration:inherit}.icon-ok-sign,.icon-remove-sign,.icon-warning-sign{border-radius:50%;font-size:13px;margin-left:5px;color:#FFF}.icon-ok-sign{background:#008000}.icon-remove-sign{background:#d10b0b}.icon-warning-sign{background:#ff8a00}.icon-ok-sign:before{content:"\f147";padding:0 1px 0 0}.icon-remove-sign:before{content:"\f335";padding:0 1px 0 0}.icon-warning-sign:before{content:"\f107"}#pdf-system-status label,label.inline-label{float:left;width:15em}#pdf-system-status strong{display:inline-block;float:left;padding-left:15px;line-height:27px}#initialisation label{line-height:26px}@media only screen and (min-width:1000px){#pdfextended-settings .leftcolumn{width:65%;float:left}#pdfextended-settings .rightcolumn{margin-left:70%}#pdf-system-status label,label.inline-label{float:none;width:auto}#pdf-system-status strong{display:inline;float:none;vertical-align:middle}[class^="icon-"],[class*=" icon-"]{vertical-align:middle}}@media only screen and (min-width:1250px){#pdf-system-status label,label.inline-label{float:left;width:15em}#pdf-system-status strong{display:inline-block;float:left}#support-request span.details.tabbed{margin-left:16em}}
1
+ #pdfextended-settings{margin-top:20px}#pdfextended-settings ol,#pdfextended-settings ul{margin-left:25px}#pdfextended-settings ul>li{list-style:disc}#pdfextended-settings ol>li{list-style:decimal}#pdfextended-settings ol li>ul,#pdfextended-settings ul li>ul{margin:5px 0 0 20px}#pdfextended-settings ul ul>li{list-style:circle}#pdfextended-settings ol ul>li{list-style:disc}#gform_tab_group #icon-gf_edit_forms{display:none}.detailed_pdf{clear:left;margin-bottom:3px}.detailed_pdf span{display:block;padding:2px 0 2px 2px}#support-request label{display:block;font-weight:bold}#pdf-system-status{overflow:hidden}#pdf-system-status p{clear:left}#pdf-system-status span.details,#support-request span.details{font-size:95%;color:#444;padding-top:7px;display:block;clear:left;}#support-request input,#support-request select{width:20em}#support-request input[type="submit"]{width:auto}#support-request textarea{width:65%;height:150px}#support-request input,#support-request textarea{padding:5px 4px}#support-request #support-request-button{padding:0 8px}#support-request .gfspinner{vertical-align:middle;margin-left:5px}#support-request textarea{border:1px solid #999;color:#444}#support-request :disabled,#support-request textarea:disabled{color:#CCC;border:1px solid #CCC}#support-request input.error,#support-request textarea.error,#support-request select.error{color:#d10b0b;border:1px solid #d10b0b}#support-request .icon-remove-sign{vertical-align:middle}.icon-spinner{font-size:18px;margin-left:5px}#support-request span.msg{margin-left:5px;color:#008000}#support-request span.error{margin-left:5px;color:#d10b0b}#pdfextended-settings #changelog h3{margin-top:20px}#pdfextended-settings div.notice{margin:5px 15px 2px;padding:0 .6em}#pdfextended-settings div.notice{background-color:#fff;border-left:4px solid #7ad03a;box-shadow:0 1px 1px 0 rgba(0,0,0,0.1)}.wrap #pdfextended-settings div.notice{margin:5px 0 15px;padding:1px 12px}div.notice p{margin:.5em 0;padding:2px}[class^="icon-"]:before,[class*=" icon-"]:before{display:inline-block;text-decoration:inherit;-webkit-font-smoothing:antialiased}[class^="icon-"],[class*=" icon-"]{background-image:none;background-position:0 0;background-repeat:repeat;display:inline;height:auto;line-height:normal;margin-top:0;vertical-align:baseline;width:auto;-webkit-font-smoothing:antialiased}[class^="icon-"],[class*=" icon-"]{font-family:"dashicons";font-style:normal;font-weight:normal;text-decoration:inherit}.icon-ok-sign,.icon-remove-sign,.icon-warning-sign{border-radius:50%;font-size:13px;margin-left:5px;color:#FFF}.icon-ok-sign{background:#008000}.icon-remove-sign{background:#d10b0b}.icon-warning-sign{background:#ff8a00}.icon-ok-sign:before{content:"\f147";padding:0 1px 0 0}.icon-remove-sign:before{content:"\f335";padding:0 1px 0 0}.icon-warning-sign:before{content:"\f107"}#pdf-system-status label,label.inline-label{float:left;width:15em}#pdf-system-status strong{display:inline-block;float:left;padding-left:15px;line-height:27px}#initialisation label{line-height:26px}@media only screen and (min-width:1000px){#pdfextended-settings .leftcolumn{width:65%;float:left}#pdfextended-settings .rightcolumn{margin-left:70%}#pdf-system-status label,label.inline-label{float:none;width:auto}#pdf-system-status strong{display:inline;float:none;vertical-align:middle}[class^="icon-"],[class*=" icon-"]{vertical-align:middle}}@media only screen and (min-width:1250px){#pdf-system-status label,label.inline-label{float:left;width:15em}#pdf-system-status strong{display:inline-block;float:left}#support-request span.details.tabbed{margin-left:16em}}
tests/bootstrap.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $_tests_dir = getenv('WP_TESTS_DIR');
4
+ if ( !$_tests_dir ) $_tests_dir = '/tmp/wordpress-tests-lib';
5
+
6
+ require_once $_tests_dir . '/includes/functions.php';
7
+
8
+ function _manually_load_plugin() {
9
+ require dirname( __FILE__ ) . '/../../gravityforms/gravityforms.php';
10
+ require dirname( __FILE__ ) . '/../pdf.php';
11
+ }
12
+ tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' );
13
+
14
+ require $_tests_dir . '/includes/bootstrap.php';
15
+
tests/test-configuration.php ADDED
@@ -0,0 +1,260 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Test_PDFConfiguration extends WP_UnitTestCase {
4
+
5
+ public function setUp() {
6
+ parent::setUp();
7
+
8
+ /* Load our plugin functions */
9
+ GFPDF_Core::fully_loaded_admin();
10
+
11
+ /* remove the configuration file */
12
+ if(file_exists(PDF_TEMPLATE_LOCATION . 'configuration.php'))
13
+ unlink(PDF_TEMPLATE_LOCATION . 'configuration.php');
14
+
15
+ global $gfpdf;
16
+ $gfpdf = new GFPDF_Core();
17
+
18
+ $gfpdf->configuration = array(
19
+ array(
20
+ 'form_id' => 1,
21
+ 'template' => 'example-template.php',
22
+ 'filename' => 'testform.pdf',
23
+ ),
24
+
25
+ array(
26
+ 'form_id' => 1,
27
+ 'template' => 'example-template-2.php',
28
+ 'filename' => 'seconddoc.pdf',
29
+ ),
30
+
31
+ array(
32
+ 'form_id' => 2,
33
+ 'template' => 'default-template.php',
34
+ ),
35
+
36
+ array(
37
+ 'form_id' => 4,
38
+ 'template' => 'my-custom-template.php',
39
+ 'security' => true,
40
+ 'pdf_master_password' => 'admin password',
41
+ ),
42
+
43
+ array(
44
+ 'form_id' => 5,
45
+ 'template' => 'default-template-no-style.php',
46
+ 'default-show-html' => true,
47
+ 'default-show-empty' => false,
48
+ 'default-show-page-names' => true,
49
+ ),
50
+ );
51
+
52
+ /* reenable the configuration */
53
+ $gfpdf->disabled = false;
54
+
55
+ /* reset the index */
56
+ $gfpdf->index = array();
57
+
58
+ /* init config index */
59
+ $this->set_form_pdfs();
60
+ }
61
+
62
+ public function set_form_pdfs()
63
+ {
64
+ global $gfpdf;
65
+
66
+ foreach($gfpdf->configuration as $key => $config)
67
+ {
68
+ if(!is_array($config['form_id']))
69
+ {
70
+ $gfpdf->assign_index($config['form_id'], $key);
71
+ }
72
+ else
73
+ {
74
+ foreach($config['form_id'] as $id)
75
+ {
76
+ $gfpdf->assign_index($id, $key);
77
+ }
78
+ }
79
+
80
+ }
81
+ }
82
+
83
+ public function tearDown() {
84
+ parent::tearDown();
85
+ }
86
+
87
+ /**
88
+ * Check if the configuration nodes are being stored correctly
89
+ */
90
+ public function test_get_config()
91
+ {
92
+ global $gfpdf;
93
+
94
+ $form1_config_nodes = $gfpdf->get_form_configuration(1);
95
+ $form2_config_nodes = $gfpdf->get_form_configuration(2);
96
+ $form3_config_nodes = $gfpdf->get_form_configuration(3);
97
+ $form4_config_nodes = $gfpdf->get_form_configuration(4);
98
+ $form5_config_nodes = $gfpdf->get_form_configuration(5);
99
+
100
+ /* Check the config array sizes are correct */
101
+ $this->assertEquals(sizeof($form1_config_nodes), 2);
102
+ $this->assertEquals(sizeof($form2_config_nodes), 1);
103
+ $this->assertEquals($form3_config_nodes, false);
104
+
105
+ /* Check that our configuration data matches */
106
+ $this->assertEquals($form1_config_nodes[0]['template'], 'example-template.php');
107
+ $this->assertEquals($form1_config_nodes[0]['filename'], 'testform.pdf');
108
+ $this->assertEquals($form1_config_nodes[1]['filename'], 'seconddoc.pdf');
109
+
110
+ $this->assertEquals($form2_config_nodes[0]['template'], 'default-template.php');
111
+
112
+ $this->assertTrue($form4_config_nodes[0]['security']);
113
+ $this->assertEquals($form4_config_nodes[0]['pdf_master_password'], 'admin password');
114
+
115
+ $this->assertTrue($form5_config_nodes[0]['default-show-html']);
116
+ $this->assertFalse($form5_config_nodes[0]['default-show-empty']);
117
+ $this->assertTrue($form5_config_nodes[0]['default-show-page-names']);
118
+ }
119
+
120
+ /*
121
+ * Check that the config index (stored by form ID) is being correctly populated
122
+ */
123
+ public function test_config_index()
124
+ {
125
+ global $gfpdf;
126
+
127
+ $this->assertEquals(sizeof($gfpdf->get_config(1)), 2);
128
+ $this->assertEquals(sizeof($gfpdf->get_config(2)), 1);
129
+ $this->assertFalse($gfpdf->get_config(3));
130
+ }
131
+
132
+ /*
133
+ * Check that the template default values are being stored correctly
134
+ */
135
+ public function test_default_config_data()
136
+ {
137
+ global $gfpdf;
138
+
139
+ $form1 = $gfpdf->get_default_config_data(1);
140
+ $form2 = $gfpdf->get_default_config_data(2);
141
+ $form5 = $gfpdf->get_default_config_data(5);
142
+
143
+ $this->assertFalse($form1['html_field'], false);
144
+ $this->assertFalse($form1['empty_field'], false);
145
+ $this->assertFalse($form1['page_names'], false);
146
+
147
+ $this->assertFalse($form2['html_field'], false);
148
+ $this->assertFalse($form2['empty_field'], false);
149
+ $this->assertFalse($form2['page_names'], false);
150
+
151
+ $this->assertTrue($form5['html_field'], true);
152
+ $this->assertFalse($form5['empty_field'], false);
153
+ $this->assertTrue($form5['page_names'], true);
154
+ }
155
+
156
+ /*
157
+ * Check that our configuration data is being pulled correctly when referenced by an ID
158
+ */
159
+ public function test_pull_config_data()
160
+ {
161
+ global $gfpdf;
162
+
163
+ $_GET['aid'] = 1;
164
+ $form1 = $gfpdf->pull_config_data(1);
165
+ $this->assertEquals($form1['filename'], 'testform.pdf');
166
+
167
+ $_GET['aid'] = 2;
168
+ $form1 = $gfpdf->pull_config_data(1);
169
+ $this->assertEquals($form1['filename'], 'seconddoc.pdf');
170
+
171
+ unset($_GET['aid']);
172
+ $form3 = $gfpdf->pull_config_data(3);
173
+ $this->assertFalse($form3);
174
+
175
+ $form4 = $gfpdf->pull_config_data(4);
176
+ $this->assertEquals($form4['pdf_master_password'], 'admin password');
177
+ }
178
+
179
+ /*
180
+ * Test that the correct template is being pulled from the configuration
181
+ */
182
+ public function test_get_template()
183
+ {
184
+ global $gfpdf;
185
+
186
+ /*
187
+ * Test that if the defaults template is disabled that no template is returned
188
+ */
189
+ define('GFPDF_SET_DEFAULT_TEMPLATE', false);
190
+ $this->assertFalse($gfpdf->get_template(10));
191
+
192
+ $this->assertEquals($gfpdf->get_template(1), 'example-template.php');
193
+
194
+ $form1_results = $gfpdf->get_template(1,true);
195
+ $this->assertEquals(sizeof($form1_results), 2);
196
+ $this->assertEquals($form1_results[1]['template'], 'example-template-2.php');
197
+ $this->assertEquals($form1_results[1]['filename'], 'seconddoc.pdf');
198
+ }
199
+
200
+ /**
201
+ * TODO
202
+ */
203
+ public function test_get_pdf_name()
204
+ {
205
+
206
+ }
207
+
208
+ /**
209
+ * Write a stub to test a number of filename options
210
+ * We won't be testing form or lead merge tag data at this stage
211
+ * Just the basic naming convention (see common functions tests for full naming tests)
212
+ *
213
+ * @dataProvider provider_test_pdf_name
214
+ */
215
+ public function test_pdf_name($test, $result)
216
+ {
217
+ $this->assertEquals(PDF_Common::validate_pdf_name($test), $result);
218
+ }
219
+
220
+ public function provider_test_pdf_name()
221
+ {
222
+ return array(
223
+ array('This is my cool pdf name.pdf', 'This is my cool pdf name.pdf'),
224
+ array("I'm using // a-bunc_&of@192 Weird <characters>.pdf", "I'm using -- a-bunc_&of@192 Weird -characters-.pdf"),
225
+ array('My document name', 'My document name.pdf'),
226
+ array('Naming.convension.pdf', 'Naming_convension.pdf'),
227
+ array('|H@xor|.pdf', '-H@xor-.pdf'),
228
+ array('A lot "of" *symbols* in:this \one.pdf', 'A lot -of- -symbols- in-this -one.pdf'),
229
+ array('Can I have a question?.pdf', 'Can I have a question-.pdf'),
230
+ );
231
+ }
232
+
233
+ /**
234
+ * Test if an array of test data will pass or fail
235
+ *
236
+ * @dataProvider provider_test_privileges
237
+ */
238
+ public function test_validate_privileges($test, $expectedResults)
239
+ {
240
+ global $gfpdf;
241
+
242
+ $validated_results = array_values($gfpdf->validate_privileges($test));
243
+
244
+ $this->assertEquals($validated_results, array_values($expectedResults));
245
+ }
246
+
247
+ public function provider_test_privileges()
248
+ {
249
+ return array(
250
+ array(array('copy', 'print', 'modify', 'annot-forms', 'fill-forms', 'extract', 'assemble', 'print-highres'), array('copy', 'print', 'modify', 'annot-forms', 'fill-forms', 'extract', 'assemble', 'print-highres')),
251
+ array(array('data', 'copy', 'print', 'food', 'modify', 'monkey-business', 'annot-forms', 'indéfini', 'fill-forms', 'extract', 'assemble', 'print-highres'), array('copy', 'print', 'modify', 'annot-forms', 'fill-forms', 'extract', 'assemble', 'print-highres')),
252
+ array(array('con caracteres', 'modify', 'extract', '123'), array('modify', 'extract')),
253
+ array('food', array()),
254
+ array(20, array()),
255
+ array(true, array()),
256
+ );
257
+ }
258
+
259
+ }
260
+
tests/test-core.php ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Test_PDFCore extends WP_UnitTestCase {
4
+ public function setUp() {
5
+ parent::setUp();
6
+
7
+ /* Load our plugin functions */
8
+ GFPDF_Core::fully_loaded_admin();
9
+
10
+ touch(PDF_TEMPLATE_LOCATION . 'configuration.php');
11
+
12
+ global $gfpdf;
13
+ $gfpdf = new GFPDF_Core();
14
+ }
15
+
16
+ public function tearDown() {
17
+ parent::tearDown();
18
+ }
19
+
20
+ public function test_helperFiles() {
21
+ $this->assertFileExists( PDF_PLUGIN_DIR . 'helper/api.php' );
22
+ $this->assertFileExists( PDF_PLUGIN_DIR . 'helper/data.php' );
23
+ $this->assertFileExists( PDF_PLUGIN_DIR . 'helper/notices.php' );
24
+ $this->assertFileExists( PDF_PLUGIN_DIR . 'helper/pdf-configuration-indexer.php' );
25
+ $this->assertFileExists( PDF_PLUGIN_DIR . 'helper/installation-update-manager.php' );
26
+ $this->assertFileExists( PDF_PLUGIN_DIR . 'helper/pdf-common.php' );
27
+
28
+ }
29
+
30
+ public function test_coreFiles() {
31
+ $this->assertFileExists( PDF_PLUGIN_DIR . 'pdf-settings.php' );
32
+ $this->assertFileExists( PDF_PLUGIN_DIR . 'model/pdf.php' );
33
+ $this->assertFileExists( PDF_PLUGIN_DIR . 'model/settings.php' );
34
+ }
35
+
36
+ public function test_gravityforms_exists() {
37
+ $this->assertTrue(class_exists('GFForms'), true);
38
+ }
39
+
40
+ public function test_pdfextended_exists() {
41
+ $this->assertTrue(class_exists('GFPDF_Core'));
42
+ $this->assertTrue(class_exists('PDFGenerator'));
43
+ $this->assertTrue(class_exists('PDF_Common'));
44
+
45
+ $this->assertTrue(class_exists('PDFRender'));
46
+ $this->assertTrue(class_exists('GFPDFEntryDetail'));
47
+ }
48
+
49
+ public function test_gravityform_compatible() {
50
+ global $gfpdfe_data;
51
+ $this->assertTrue($gfpdfe_data->gf_is_compatible);
52
+ }
53
+
54
+ public function test_wp_compatible() {
55
+ global $gfpdfe_data;
56
+ $this->assertTrue($gfpdfe_data->wp_is_compatible);
57
+ }
58
+
59
+ public function test_mb_string_installed() {
60
+ global $gfpdfe_data;
61
+ $this->assertTrue($gfpdfe_data->mb_string_installed);
62
+ }
63
+
64
+ public function test_gd_installed() {
65
+ global $gfpdfe_data;
66
+ $this->assertTrue($gfpdfe_data->gd_installed);
67
+ }
68
+
69
+ public function test_ram_compatible() {
70
+ global $gfpdfe_data;
71
+
72
+ $this->assertTrue($gfpdfe_data->ram_compatible);
73
+ }
74
+
75
+ public function test_major_compatibility() {
76
+ $this->assertTrue(GFPDF_Core_Model::check_major_compatibility());
77
+ }
78
+
79
+ public function test_write_access() {
80
+ $access_type = get_filesystem_method();
81
+
82
+ $this->assertEquals($access_type, 'direct');
83
+
84
+ global $gfpdfe_data;
85
+ $this->assertTrue($gfpdfe_data->automated);
86
+ }
87
+
88
+ public function test_fully_installed() {
89
+ $this->assertTrue(GFPDF_Core_Model::is_fully_installed());
90
+ }
91
+
92
+ public function test_configuration_file() {
93
+ $this->assertEquals(file_exists(PDF_TEMPLATE_LOCATION . 'configuration.php'), true);
94
+
95
+ global $gfpdf;
96
+ $this->assertEquals($gfpdf->disabled, false);
97
+
98
+ }
99
+
100
+
101
+ }
102
+
tests/test-gravity-forms.php ADDED
@@ -0,0 +1,140 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * PDF Extended integrates directly with Gravity Forms
5
+ * Breakages can occur if the plugin starts returning results which
6
+ * differ from what we expected.
7
+ *
8
+ * This class will test all the functions we use in the software to
9
+ * ensure we maintain compatibility.
10
+ */
11
+ class Test_GravityForms extends WP_UnitTestCase {
12
+ private $form_id = false;
13
+ private $entries = array();
14
+
15
+ public function setUp() {
16
+ parent::setUp();
17
+
18
+ GFForms::setup();
19
+
20
+ /* Load our plugin functions */
21
+ GFPDF_Core::fully_loaded_admin();
22
+
23
+ touch(PDF_TEMPLATE_LOCATION . 'configuration.php');
24
+
25
+ global $gfpdf;
26
+ $gfpdf = new GFPDF_Core();
27
+
28
+ $this->create_form_and_entries();
29
+ }
30
+
31
+ public function tearDown() {
32
+ parent::tearDown();
33
+ }
34
+
35
+ public function create_form_and_entries() {
36
+ $this->create_forms();
37
+ $this->create_entries();
38
+ }
39
+
40
+ public function create_forms()
41
+ {
42
+ $form = json_decode('{"title":"Simple Form Testing","description":"","labelPlacement":"top_label","descriptionPlacement":"below","button":{"type":"text","text":"Submit","imageUrl":""},"fields":[{"id":1,"label":"Name","adminLabel":"","type":"name","isRequired":false,"size":"medium","errorMessage":"","inputs":[{"id":1.3,"label":"First","name":""},{"id":1.6,"label":"Last","name":""}],"formId":47,"pageNumber":1,"descriptionPlacement":"below"},{"id":2,"label":"Address","adminLabel":"","type":"address","isRequired":false,"size":"medium","errorMessage":"","inputs":[{"id":2.1,"label":"Street Address","name":""},{"id":2.2,"label":"Address Line 2","name":""},{"id":2.3,"label":"City","name":""},{"id":2.4,"label":"State \/ Province","name":""},{"id":2.5,"label":"ZIP \/ Postal Code","name":""},{"id":2.6,"label":"Country","name":""}],"formId":47,"pageNumber":1,"descriptionPlacement":"below"},{"id":3,"label":"Email","adminLabel":"","type":"email","isRequired":false,"size":"medium","errorMessage":"","inputs":null,"formId":47,"pageNumber":1,"descriptionPlacement":"below"},{"id":4,"label":"Phone","adminLabel":"","type":"phone","isRequired":false,"size":"medium","errorMessage":"","inputs":null,"phoneFormat":"standard","formId":47,"pageNumber":1,"descriptionPlacement":"below"},{"id":5,"label":"Untitled","adminLabel":"","type":"select","isRequired":false,"size":"medium","errorMessage":"","inputs":null,"choices":[{"text":"First Choice","value":"First Choice","isSelected":false,"price":""},{"text":"Second Choice","value":"Second Choice","isSelected":false,"price":""},{"text":"Third Choice","value":"Third Choice","isSelected":false,"price":""}],"formId":47,"pageNumber":1,"descriptionPlacement":"below"},{"id":6,"label":"Untitled","adminLabel":"","type":"multiselect","isRequired":false,"size":"medium","errorMessage":"","inputs":null,"choices":[{"text":"First Choice","value":"First Choice","isSelected":false,"price":""},{"text":"Second Choice","value":"Second Choice","isSelected":false,"price":""},{"text":"Third Choice","value":"Third Choice","isSelected":false,"price":""}],"formId":47,"pageNumber":1,"descriptionPlacement":"below"},{"id":7,"label":"Untitled","adminLabel":"","type":"textarea","isRequired":false,"size":"medium","errorMessage":"","inputs":null,"formId":47,"pageNumber":1,"descriptionPlacement":"below"}],"id":47,"useCurrentUserAsAuthor":true,"postContentTemplateEnabled":false,"postTitleTemplateEnabled":false,"postTitleTemplate":"","postContentTemplate":"","lastPageButton":null,"pagination":null,"firstPageCssClass":null,"notifications":{"5414ff2b70018":{"id":"5414ff2b70018","to":"{admin_email}","name":"Admin Notification","event":"form_submission","toType":"email","subject":"New submission from {form_title}","message":"{all_fields}"},"5414ff5a5a28a":{"isActive":true,"id":"5414ff5a5a28a","name":"User Notification","event":"form_submission","to":"3","toType":"field","bcc":"","subject":"Email Notification","message":"User Notification","from":"{admin_email}","fromName":"","replyTo":"","routing":null,"conditionalLogic":null,"disableAutoformat":""}},"confirmations":{"5414ff2b752f0":{"id":"5414ff2b752f0","name":"Default Confirmation","isDefault":true,"type":"message","message":"Thanks for contacting us! We will get in touch with you shortly.","url":"","pageId":"","queryString":""}},"is_active":"1","date_created":"2014-09-14 02:36:27","is_trash":"0"}', true);
43
+
44
+ $results = GFAPI::add_form($form);
45
+
46
+ /* test the form was correctly added to the database */
47
+ $this->assertInternalType("int", $results);
48
+ $this->form_id = $results;
49
+ }
50
+
51
+ public function create_entries()
52
+ {
53
+ $entries = json_decode('[{"id":"453","form_id":"47","date_created":"2014-09-14 02:47:14","is_starred":0,"is_read":0,"ip":"144.131.91.23","source_url":"http:\/\/clients.blueliquiddesigns.com.au\/gfpdf3\/gf1_7\/wordpress\/?gf_page=preview&id=47","post_id":null,"currency":"USD","payment_status":null,"payment_date":null,"transaction_id":null,"payment_amount":null,"payment_method":null,"is_fulfilled":null,"created_by":"1","transaction_type":null,"user_agent":"Mozilla\/5.0 (Windows NT 6.1; WOW64; rv:32.0) Gecko\/20100101 Firefox\/32.0","status":"active","1.3":"My","1.6":"Name","5":"First Choice","2.1":"","2.2":"","2.3":"","2.4":"","2.5":"","2.6":"","3":"","4":"","6":"","7":""},{"id":"452","form_id":"47","date_created":"2014-09-14 02:47:06","is_starred":0,"is_read":0,"ip":"144.131.91.23","source_url":"http:\/\/clients.blueliquiddesigns.com.au\/gfpdf3\/gf1_7\/wordpress\/?gf_page=preview&id=47","post_id":null,"currency":"USD","payment_status":null,"payment_date":null,"transaction_id":null,"payment_amount":null,"payment_method":null,"is_fulfilled":null,"created_by":"1","transaction_type":null,"user_agent":"Mozilla\/5.0 (Windows NT 6.1; WOW64; rv:32.0) Gecko\/20100101 Firefox\/32.0","status":"active","1.3":"First","1.6":"Last","2.1":"12 Alister St","2.3":"Ali","2.4":"State","2.5":"2678","2.6":"Barbados","3":"my@test.com","4":"(345)445-4566","5":"Second Choice","6":"First Choice,Second Choice,Third Choice","2.2":"","7":""},{"id":"451","form_id":"47","date_created":"2014-09-14 02:46:35","is_starred":0,"is_read":0,"ip":"144.131.91.23","source_url":"http:\/\/clients.blueliquiddesigns.com.au\/gfpdf3\/gf1_7\/wordpress\/?gf_page=preview&id=47","post_id":null,"currency":"USD","payment_status":null,"payment_date":null,"transaction_id":null,"payment_amount":null,"payment_method":null,"is_fulfilled":null,"created_by":"1","transaction_type":null,"user_agent":"Mozilla\/5.0 (Windows NT 6.1; WOW64; rv:32.0) Gecko\/20100101 Firefox\/32.0","status":"active","1.3":"Jake","1.6":"Jackson","2.1":"123 Fake St","2.2":"Line 2","2.3":"City","2.4":"State","2.5":"2441","2.6":"Albania","3":"test@test.com","4":"(123)123-1234","5":"Third Choice","6":"Second Choice,Third Choice","7":"This is paragraph test!"}]', true);
54
+
55
+ $results = GFAPI::add_entries($entries, $this->form_id);
56
+
57
+ /* test we get the correct results */
58
+ $this->assertEquals(true, is_array($results));
59
+
60
+ $this->entries = $results;
61
+ }
62
+
63
+ /*
64
+ * Test GF replace variables function (merge tags)
65
+ * i.e GFCommon::replace_variables
66
+ */
67
+ public function test_replace_variables()
68
+ {
69
+
70
+ }
71
+
72
+ /*
73
+ * Test Gravity Form user privlages
74
+ * i.e GFCommon::current_user_can_any("gravityforms_view_entries")
75
+ */
76
+ public function test_gf_privs()
77
+ {
78
+ /* create user using WP Unit Factory functions */
79
+ }
80
+
81
+ /**
82
+ * Test that the correct IP is returned by the function
83
+ * @param String $ip The test IP address
84
+ * @param String $var The $_SERVER array key
85
+ *
86
+ * @dataProvider provider_ip_testing
87
+ */
88
+ public function run_ip_test($ip, $var)
89
+ {
90
+ $_SERVER[$var] = $ip;
91
+ $this->assertEquals($ip, GFFormsModel::get_ip());
92
+ unset($_SERVER[$var]);
93
+ }
94
+
95
+ /**
96
+ * The data provider for the run_ip_test() function
97
+ */
98
+ public function provider_ip_testing()
99
+ {
100
+ return array(
101
+ array('5.120.2.1', 'HTTP_CLIENT_IP'),
102
+ array('6.10.3.9', 'HTTP_X_FORWARDED_FOR'),
103
+ array('7.60.126.3', 'REMOTE_ADDR'),
104
+ array('240.24.12.44,5.120.2.1', 'HTTP_CLIENT_IP'),
105
+ array('10.17.54.234,6.10.3.9', 'HTTP_X_FORWARDED_FOR'),
106
+ array('7.60.126.3,65.4.69.129', 'REMOTE_ADDR'),
107
+ );
108
+ }
109
+
110
+ /*
111
+ * Test that GFForms::$version will produce
112
+ * the expected result.
113
+ */
114
+ public function test_gf_version()
115
+ {
116
+ $version = GFForms::$version;
117
+
118
+ /* which the version number is a string before we try to match it */
119
+ $this->assertEquals(true, is_string($version));
120
+
121
+ /* do a final test to match the version number according to a set standard */
122
+ $this->assertRegExp('/^(?:(\d+)\.)?(?:(\d+)\.)?(\*|\d+)$/', $version);
123
+ }
124
+
125
+ /*
126
+ * Test Gravity Form actions and filter
127
+ */
128
+
129
+ /* 'gform_after_submission' */
130
+ public function test_after_submission()
131
+ {
132
+
133
+ }
134
+
135
+ /* 'gform_notification' */
136
+ public function test_notifications()
137
+ {
138
+
139
+ }
140
+ }
tests/test-hooks.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PDF_Actions_And_Filters extends WP_UnitTestCase {
4
+ public function setUp() {
5
+ parent::setUp();
6
+
7
+ /* Load our plugin functions */
8
+ GFPDF_Core::fully_loaded_admin();
9
+
10
+ global $gfpdf;
11
+ $gfpdf = new GFPDF_Core();
12
+ }
13
+
14
+ public function tearDown() {
15
+ parent::tearDown();
16
+ }
17
+
18
+ public function test_actions_hook() {
19
+
20
+
21
+ $this->assertEquals(10, has_action('init', array('GFPDF_Core', 'pdf_init')));
22
+ $this->assertEquals(9999, has_action('admin_init', array('GFPDF_Core', 'fully_loaded_admin')));
23
+
24
+ $this->assertEquals(10, has_action('after_switch_theme', array('GFPDF_InstallUpdater', 'gf_pdf_on_switch_theme')));
25
+ $this->assertEquals(10, has_action('wp_ajax_support_request', array('GFPDF_Settings_Model', 'gfpdf_support_request')));
26
+
27
+ $this->assertEquals(9, has_action('admin_init', array('GFPDF_Core', 'gfe_admin_init')));
28
+
29
+ $this->assertEquals(10, has_action('gform_entries_first_column_actions', array('GFPDF_Core_Model', 'pdf_link')));
30
+ $this->assertEquals(10, has_action('gform_entry_info', array('GFPDF_Core_Model', 'detail_pdf_link')));
31
+ $this->assertEquals(10, has_action('wp', array('GFPDF_Core_Model', 'process_exterior_pages')));
32
+ $this->assertEquals(10, has_action('gform_after_submission', array('GFPDF_Core_Model', 'gfpdfe_save_pdf')));
33
+
34
+ }
35
+
36
+ public function test_filter_hooks() {
37
+
38
+ $this->assertEquals(10, has_filter('gfpdfe_pdf_template', array('PDF_Common', 'do_mergetags')));
39
+ $this->assertEquals(10, has_filter('gfpdfe_pdf_template', 'do_shortcode'));
40
+
41
+ $this->assertEquals(100, has_filter('gform_notification', array('GFPDF_Core_Model', 'gfpdfe_create_and_attach_pdf')));
42
+ }
43
+
44
+
45
+ }
tests/test-pdf-model.php ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Test_PDFModel extends WP_UnitTestCase {
4
+ public function setUp() {
5
+ parent::setUp();
6
+
7
+ /* Load our plugin functions */
8
+ GFPDF_Core::fully_loaded_admin();
9
+
10
+ touch(PDF_TEMPLATE_LOCATION . 'configuration.php');
11
+
12
+ global $gfpdf;
13
+ $gfpdf = new GFPDF_Core();
14
+ }
15
+
16
+ public function tearDown() {
17
+ parent::tearDown();
18
+ }
19
+
20
+ public function test_process_exterior_pages()
21
+ {
22
+ //wp_set_current_user(1);
23
+ }
24
+
25
+ public function test_do_notification()
26
+ {
27
+
28
+ }
29
+
30
+ public function test_check_notification()
31
+ {
32
+
33
+ }
34
+
35
+ public function test_get_notifications_name()
36
+ {
37
+
38
+ }
39
+
40
+ public function test_get_form_notifications()
41
+ {
42
+
43
+ }
44
+
45
+ public function test_generate_pdf_parameters()
46
+ {
47
+
48
+ }
49
+
50
+ public function test_check_configuration()
51
+ {
52
+
53
+ }
54
+
55
+ public function test_valid_gravity_forms()
56
+ {
57
+
58
+ }
59
+
60
+ public function test_check_major_compatibility()
61
+ {
62
+
63
+ }
64
+ }
65
+
view/templates/settings/changelog.php CHANGED
@@ -21,7 +21,12 @@
21
  <p><strong>Current Version: <?php echo PDF_EXTENDED_VERSION; ?></strong></p>
22
 
23
  <h3><?php echo PDF_EXTENDED_VERSION; ?></h3>
 
 
 
 
24
 
 
25
  <ul>
26
  <li>Bug - Fixed issue with last release that affected checks to see if Gravity Forms has submitting</li>
27
  <li>Bug - Fixed fatal error with servers using PHP5.2 or lower</li>
21
  <p><strong>Current Version: <?php echo PDF_EXTENDED_VERSION; ?></strong></p>
22
 
23
  <h3><?php echo PDF_EXTENDED_VERSION; ?></h3>
24
+ <ul>
25
+ <li>Bug - Fixed issue where the PDF settings page was blank for some users</li>
26
+ </ul>
27
+
28
 
29
+ <h3>3.5.6</h3>
30
  <ul>
31
  <li>Bug - Fixed issue with last release that affected checks to see if Gravity Forms has submitting</li>
32
  <li>Bug - Fixed fatal error with servers using PHP5.2 or lower</li>