Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
project
webform_encrypt
Commits
d91de250
Commit
d91de250
authored
Jun 08, 2011
by
Jake Bell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding match user feature.
parent
16328b7f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
1 deletion
+34
-1
webform_encrypt.install
webform_encrypt.install
+5
-0
webform_encrypt.module
webform_encrypt.module
+29
-1
No files found.
webform_encrypt.install
0 → 100644
View file @
d91de250
<?php
function
webform_encrypt_uninstall
()
{
variable_del
(
'webform_encrypt_match_user'
);
}
webform_encrypt.module
View file @
d91de250
...
...
@@ -16,6 +16,23 @@ function webform_encrypt_permission() {
* Implementation of hook_form_alter()
*/
function
webform_encrypt_form_alter
(
&
$form
,
$form_state
,
$form_id
)
{
// Add our config options to the webform settings page.
if
(
$form_id
==
'webform_admin_settings'
)
{
dsm
(
$form
);
$form
[
'encrypt'
]
=
array
(
'#type'
=>
'fieldset'
,
'#title'
=>
t
(
'Webform Encrypt'
),
'#collapsible'
=>
TRUE
,
'#collapsed'
=>
FALSE
,
);
$form
[
'encrypt'
][
'webform_encrypt_match_user'
]
=
array
(
'#type'
=>
'checkbox'
,
'#title'
=>
t
(
'Enable email to user matching'
),
'#description'
=>
t
(
'If enabled, every time webform sends an email, it will attempt to find a user that matches the email address the mail will be sent to in order to correctly determine permissions.'
),
'#default_value'
=>
variable_get
(
'webform_encrypt_match_user'
,
0
),
);
}
// Add our fields to the component add/edit form.
if
(
$form_id
==
'webform_component_edit_form'
)
{
...
...
@@ -69,11 +86,22 @@ function webform_encrypt_webform_submission_presave($node, &$submission) {
* Decrypt values when displaying webform submissions.
*/
function
webform_encrypt_webform_submission_render_alter
(
&
$renderable
)
{
// First, determine if 1) if we are dealing with an email or a page view, and 2) if user matching
// is enabled.
if
(
variable_get
(
'webform_encrypt_match_user'
,
FALSE
)
&&
!
empty
(
$renderable
[
'#email'
]))
{
// If we are, then try to match a user to the email address we are sending to.
$uid
=
db_query
(
'SELECT uid FROM {users} WHERE mail = ?'
,
array
(
$renderable
[
'#email'
][
'email'
]))
->
fetchField
();
$account
=
$uid
?
user_load
(
$uid
)
:
NULL
;
}
else
{
$account
=
NULL
;
}
// Next, we loop through components and decrypt as necessary.
foreach
(
$renderable
[
'#submission'
]
->
data
as
$cid
=>
$entry
)
{
if
(
isset
(
$renderable
[
'#node'
]
->
webform
[
'components'
][
$cid
][
'extra'
][
'encrypt'
])
&&
$renderable
[
'#node'
]
->
webform
[
'components'
][
$cid
][
'extra'
][
'encrypt'
])
{
$form_key
=
$renderable
[
'#node'
]
->
webform
[
'components'
][
$cid
][
'form_key'
];
if
(
user_access
(
'view encrypted values'
))
{
if
(
user_access
(
'view encrypted values'
,
$account
))
{
$renderable
[
$form_key
][
'#value'
]
=
decrypt
(
$entry
[
'value'
][
0
],
array
(
'base64'
=>
TRUE
));
}
else
{
$renderable
[
$form_key
][
'#value'
]
=
t
(
'[Value Encrypted]'
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment