Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fillpdf-3271308
Manage
Activity
Members
Labels
Plan
Custom issue tracker
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Issue forks
fillpdf-3271308
Commits
e9a36549
Commit
e9a36549
authored
12 years ago
by
Liam Morland
Committed by
Kevin Kaland
12 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#1393012
: Allow specifying default node.
This works with Webform nodes as the node as well.
parent
fd9c0dbb
No related branches found
Branches containing commit
Tags
8.x-4.32
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
fillpdf.admin.inc
+11
-1
11 additions, 1 deletion
fillpdf.admin.inc
fillpdf.install
+13
-0
13 additions, 0 deletions
fillpdf.install
fillpdf.module
+33
-8
33 additions, 8 deletions
fillpdf.module
with
57 additions
and
9 deletions
fillpdf.admin.inc
+
11
−
1
View file @
e9a36549
e
?
php
<
?php
/**
* @file
...
...
@@ -194,6 +194,14 @@ function fillpdf_form_edit($form, &$form_state, $fid) {
'#required'
=>
TRUE
,
);
$form
[
'default_nid'
]
=
array
(
'#type'
=>
'textfield'
,
'#title'
=>
t
(
'Default Node ID'
),
'#description'
=>
t
(
'When filling a PDF, use this node for the data source if no node is specified in the Fill PDF URL.'
),
'#maxlength'
=>
10
,
'#default_value'
=>
$pdf_form
->
default_nid
,
);
// @@TODO:
// They can upload a PDF any time, but fields will only be generated on add. Don't want to purge existing fields,
// however a user might have accidently uploaded an old template and discover much later (if it's substantially different, just
...
...
@@ -321,6 +329,7 @@ function fillpdf_form_edit_submit($form, &$form_state) {
db_update
(
'fillpdf_forms'
)
->
fields
(
array
(
'title'
=>
$form_state
[
'values'
][
'title'
],
'default_nid'
=>
(
int
)
$form_state
[
'values'
][
'default_nid'
]
>
0
?
(
int
)
$form_state
[
'values'
][
'default_nid'
]
:
NULL
,
'destination_path'
=>
$form_state
[
'values'
][
'destination_path'
],
'replacements'
=>
$form_state
[
'values'
][
'replacements'
],
))
...
...
@@ -695,3 +704,4 @@ function fillpdf_update_field(&$pdf_form, &$field, $old_key) {
->
condition
(
'pdf_key'
,
$old_key
)
->
execute
();
}
This diff is collapsed.
Click to expand it.
fillpdf.install
+
13
−
0
View file @
e9a36549
...
...
@@ -24,6 +24,11 @@ function fillpdf_schema() {
'length'
=>
255
,
'not null'
=>
TRUE
,
),
'default_nid'
=>
array
(
'type'
=>
'int'
,
'unsigned'
=>
TRUE
,
'not null'
=>
FALSE
,
),
'url'
=>
array
(
'type'
=>
'varchar'
,
'length'
=>
255
,
...
...
@@ -134,3 +139,11 @@ function fillpdf_update_7003() {
variable_set
(
'fillpdf_service'
,
$variable_name_map
[
$default
]);
}
}
/**
* Add field to store default NID.
*/
function
fillpdf_update_7004
()
{
db_add_field
(
'fillpdf_forms'
,
'default_nid'
,
array
(
'type'
=>
'int'
,
'unsigned'
=>
TRUE
,
'not null'
=>
FALSE
));
}
This diff is collapsed.
Click to expand it.
fillpdf.module
+
33
−
8
View file @
e9a36549
...
...
@@ -227,7 +227,7 @@ function fillpdf_merge_pdf($fid, $nids = NULL, $webform_arr = NULL, $sample = NU
drupal_goto
();
}
$fillpdf_info
=
db_query
(
"SELECT title, url, destination_path, replacements FROM
{
fillpdf_forms
}
WHERE fid = :fid"
,
array
(
':fid'
=>
$fid
))
->
fetch
();
$fillpdf_info
=
db_query
(
"SELECT title,
default_nid,
url, destination_path, replacements FROM
{
fillpdf_forms
}
WHERE fid = :fid"
,
array
(
':fid'
=>
$fid
))
->
fetch
();
$fillpdf_info
->
replacements
=
_fillpdf_replacements_to_array
(
$fillpdf_info
->
replacements
);
// Case 2: Only $fid -- just give them empty pdf
...
...
@@ -240,6 +240,29 @@ function fillpdf_merge_pdf($fid, $nids = NULL, $webform_arr = NULL, $sample = NU
global
$user
;
$nodes
=
$webforms
=
array
();
// If $webform_arr contains entries with an sid, but not an nid, set the nid to the default.
if
(
!
empty
(
$fillpdf_info
->
default_nid
)
&&
is_array
(
$webform_arr
))
{
foreach
(
array_keys
(
$webform_arr
)
as
$key
)
{
if
(
empty
(
$webform_arr
[
$key
][
'nid'
]))
{
$webform_arr
[
$key
][
'nid'
]
=
$fillpdf_info
->
default_nid
;
}
}
}
// If no nid is given, use the default.
if
(
!
empty
(
$fillpdf_info
->
default_nid
)
&&
empty
(
$nids
)
&&
empty
(
$webform_arr
))
{
$default_node
=
node_load
(
$fillpdf_info
->
default_nid
);
if
(
$default_node
)
{
if
(
empty
(
$default_node
->
webform
))
{
// Default node is a non-webform node.
$nodes
[]
=
$default_node
;
}
else
{
// Default node is a webform.
$webform_arr
=
array
(
array
(
'nid'
=>
$fillpdf_info
->
default_nid
,
'node'
=>
$default_node
));
}
}
}
// Nodes
if
(
is_array
(
$nids
))
{
foreach
(
$nids
as
$nid
)
{
...
...
@@ -256,14 +279,16 @@ function fillpdf_merge_pdf($fid, $nids = NULL, $webform_arr = NULL, $sample = NU
}
foreach
(
$webform_arr
as
$webform
)
{
if
(
empty
(
$webform
[
'sid'
]))
{
// User did not specify submission ID, meaning they want most recent.
$webform
[
'sid'
]
=
db_query
(
'SELECT sid FROM {webform_submissions}
WHERE nid = :nid AND uid = :uid ORDER BY submitted DESC'
,
array
(
':nid'
=>
(
int
)
$webform
[
'nid'
],
':uid'
=>
(
int
)
$user
->
uid
))
->
fetchField
();
if
(
!
empty
(
$webform
[
'nid'
]))
{
if
(
empty
(
$webform
[
'sid'
]))
{
// User did not specify submission ID, meaning they want most recent.
$webform
[
'sid'
]
=
db_query
(
'SELECT sid FROM {webform_submissions}
WHERE nid = :nid AND uid = :uid ORDER BY submitted DESC'
,
array
(
':nid'
=>
$webform
[
'nid'
],
':uid'
=>
$user
->
uid
))
->
fetchField
();
}
$webforms
[]
=
array
(
'webform'
=>
empty
(
$webform
[
'node'
])
?
node_load
(
$webform
[
'nid'
])
:
$webform
[
'node'
],
'submission'
=>
webform_get_submission
(
$webform
[
'nid'
],
$webform
[
'sid'
]),
);
}
$webforms
[]
=
array
(
'webform'
=>
node_load
(
$webform
[
'nid'
]),
'submission'
=>
webform_get_submission
(
$webform
[
'nid'
],
$webform
[
'sid'
]),
);
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment