View Issue Details

This bug affects 1 person(s).
 4
IDProjectCategoryView StatusLast Update
07451Feature requestsSurvey editingpublic2021-11-15 08:54
Reporteruser10469Assigned Togalads  
PrioritynormalSeverityfeature 
Status closedResolutionfixed 
Summary07451: Email results of survey to selectable address / protect email addresses
Description

Thank you for making LimeSurvey available to the Internet community. I have a great appreciation for all of the effort that has gone into developing this application and as such I would like to contribute by proposing an idea and including a solution.

I am trying to have the results of a survey emailed to the a person listed in one of the questions. I am using the INSERTANS:... tag in the "email response to" field. So far this works in accordance with the documentation at:

http://docs.limesurvey.org/tiki-index.php?page=Creating+a+new+survey#Notification_amp_Data_Management

Ideally I would like to just display the names or job role of the recipient and not their actual email address so as to protect it from automated email address harvesters.

Here is a sample situation: A medical clinic with 20 doctors is conducting a survey. Each doctor wants to receive a copy of a completed survey from their patient. Although I could create 20 identical surveys at 20 different URL's, it would make more sense to just have one survey and have the respondent pick their doctor's name from a list.

Another reason to only want one survey is that I still want the results to be gathered into a single database so that I can generate reports and statistics for the clinic where the 20 doctors work.

Additional Information

A possible solution: Adding flexibility to an email address field.
Ideally there should be an email address field where we could specify both the name and the email address in two separate fields so that only the actual name would be displayed.

One quick fix to this problem is to modify the index.php file. Although this fix will not result in the email address being hidden, it will add the ability to specify both a name and email address in the same field, and to disguise or encode the email address itself.

By adding the following code, you get the following new functionality:

1) You can use "(at)", "(dot)" and insert spaces anywhere you want in the email address. For example:
ideas(at)lime survey(dot)org

2) You can specify an email address which is hex encoded. It's not a sophisticated encoding. For example, ideas@limesurvey.org would be 6964656173406c696d657375727665792e6f7267 (not case sensitive)

3) You can specify both a name and an email address by placing the email address between square brackets. For example: Great Ideas [ideas@limesurvey.org]

NOTE: You can use any combination of the above three options. Of course the hex version of the address is only useful if you combine it with #3 above. For example:

Great Ideas [6964656173406c696d657375727665792e6f7267]

So, here is how to implement this solution:

==== File to be modified: index.php ====

STEP 1: Add the following function right above the "sendsubmitnotification" function:

function extractemailaddress($address) // by Michael Milette (2010-10-27)

// eliminate everything outside of and including square brackets, if applicable
$start = strpos($address,'[');
if ($start > 0 && $start < strlen($address))
$end = strpos($address,']',$start+1);
if ($start > 0 && $start+1 < $end-1)
$address = substr($address,$start+1,$end-$start-1);

// Decode back to string if the email address is hex encoded
if (ctype_xdigit($address))
$address = preg_replace('#(\w)(\w)#e', "chr(hexdec('$1$2'))", $address);

// replace (at) with @, the (dot) with . and remove all spaces
$address = str_replace('(at)','@',$address);
$address = str_replace('(dot)','.',$address);
$address = str_replace(' ','',$address);

return $address;

STEP 2: modify the "sendsubmitnotification" function by adding in $ert=extractemailaddress($ert); as follows:

//Now check each of the email addresses that they are valid before creating/adding to the $emailresponseto array
foreach($emailresponsetos as $ert)

$ert=extractemailaddress($ert);
if(validate_email($ert))

  $emailresponseto[]=$ert;

That's it. You could also add a tool somewhere on the webpage to help users encode email addresses. Here is a simple Javascript function I wrote to do the encoding:

// Convert characters in a string of text to hexadecimal string
function String2Hex(txtString)
var hex = '';
for(var i=0;i<txtString.length;i++)
var h = txtString.charCodeAt(i).toString(16);
while(h.length<2) h="0"+h;
hex += h;

return hex;

Please feel free to contact me if you have any questions.

Thanks again for all your time and effort.

With best regards,

Michael Milette
TNG Consulting Inc.
www.tngconsulting.ca

TagsNo tags attached.
Bug heat4
Story point estimate
Users affected %

Users monitoring this issue

There are no users monitoring this issue.

Activities

user10469

2010-11-11 21:23

  ~24361

Sorry, seems that the curly brackets don't come through in the posts. Please contact me if you would like me to send you the complete version of the source code.

galads

galads

2021-11-15 08:54

reporter   ~67305

Hello mjm4842,

Thank you for suggesting a feature.

However, it seems the feature has been implemented already in the latest versions.

Please check on the latest versions and if the issue still exists, feel free to re-open the report.

kind regards,
galads

Issue History

Date Modified Username Field Change
2019-11-01 17:25 c_schmitz Category Survey design => Survey editing
2021-11-15 08:54 galads Note Added: 67305
2021-11-15 08:54 galads Bug heat 2 => 4
2021-11-15 08:54 galads Assigned To => galads
2021-11-15 08:54 galads Status acknowledged => closed
2021-11-15 08:54 galads Resolution open => fixed