View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
09904 | Feature requests | RemoteControl | public | 2015-09-20 23:46 | 2016-04-12 10:48 |
Reporter | oenie | Assigned To | DenisChenu | ||
Priority | normal | Severity | feature | ||
Status | closed | Resolution | fixed | ||
Product Version | 2.05+ | ||||
Summary | 09904: Variable EXPIRY of the survey can not be used in Expression when sending an email | ||||
Description | When trying to send an email through the Remote Control API, it seems that the Expression manager variable Expiry (as defined for a survey) is viewed as 'unknown'. Sending the same email through the website (via Token > Send Invitations/Reminders) does not have this problem | ||||
Steps To Reproduce |
EXPIRY is not replaced in the sent email, listed as 'unknown' by Expression Manager. | ||||
Tags | No tags attached. | ||||
Attached Files | issue_9904_expiry_token_remote_control.diff (1,180 bytes)
diff --git a/application/helpers/admin/token_helper.php b/application/helpers/admin/token_helper.php index ce4ac27..863dcb5 100644 --- a/application/helpers/admin/token_helper.php +++ b/application/helpers/admin/token_helper.php @@ -78,6 +78,7 @@ function emailTokens($iSurveyID,$aResultTokens,$sType) $fieldsarray["{ADMINNAME}"] = $oSurvey['admin']; $fieldsarray["{ADMINEMAIL}"] = $oSurvey['adminemail']; + $fieldsarray["{EXPIRY}"] = $oSurvey['expires']; $from = $fieldsarray["{ADMINNAME}"] . ' <' . $fieldsarray["{ADMINEMAIL}"] . '>'; if($from == '') $from = Yii::app()->getConfig('siteadminemail'); @@ -128,8 +129,10 @@ function emailTokens($iSurveyID,$aResultTokens,$sType) $sMessage = $aSurveyLocaleData[$sTokenLanguage]['surveyls_email_remind']; } - $modsubject = Replacefields($sSubject, $fieldsarray); - $modmessage = Replacefields($sMessage, $fieldsarray); + $modsubject = Replacefields($sSubject, $fieldsarray, false); + $modsubject = Replacefields($modsubject, $fieldsarray); + $modmessage = Replacefields($sMessage, $fieldsarray, false); + $modmessage = Replacefields($modmessage, $fieldsarray); if (isset($barebone_link)) { | ||||
Bug heat | 6 | ||||
Story point estimate | |||||
Users affected % | |||||
Do you still have the problem in the latest version? |
|
I will have to check it later this month, am currently out of the office. |
|
I have installed the recent (2.06) version of limesurvey on my local computer, and it seems to have the same problem still. It works when I send the email from the web interface, but no EXPIRY date when sending through RemoteControl. |
|
I've been looking into the problem myself and have found the following solution: The EXPIRY field was not included in the $fieldsarray in the emailTokens function (application/helpers/admin/token_helper.php) The global options, including EXPIRY, are already parsed through ReplaceFields in the views when going through the Webinterface (e.g. see the code in application/views/admin/token/invite.php), before passing to the same emailTokens function later. What is interesting to note here (a second problem for me) is that the function call to ReplaceFields in the views is used with the parameter bReplaceInsertans set to FALSE. In my own example, the EXPIRY variable was wrapped inside a function to format it according to a specific pattern ({strftime('%e %B %Y', strtotime('{EXPIRY}'))}). EXPIRY here needs to be replaced first by calling ReplaceFields with $bReplaceInsertans to FALSE, or it will be lost. To solve both problems i have added a diff to the most recent code (checked out 2.06 build 151018 with git):
Hope that helps ! |
|
Reminder sent to: c_schmitz Hi Just wondering if you have had the time to look at my suggested fix. Kind regards, Jeroen |
|
Why doing Replacefields(Replacefields($sSubject)) ? You don't have to Replacefields 2 times. |
|
It was mentioned in my previous note, and the reason of the whole problem: It is called 2 times, but once with the bReplaceInsertans to FALSE and then with it set to TRUE. Doing this allows the INSERTANS fields to be parsed to. Quote: In my own example, the EXPIRY variable was wrapped inside a function to format it according to a specific pattern ({strftime('%e %B %Y', strtotime('{EXPIRY}'))}). EXPIRY here needs to be replaced first by calling ReplaceFields with $bReplaceInsertans to FALSE, or it will be lost. |
|
You don't have to add the { inside an expression .... {strftime('%e %B %Y', strtotime(EXPIRY))}) Musty work (and if not : must be fixed) |
|
I'm afraid that does not work, and i wasn't expecting it to. What if i wanted to use a function to concatenate a piece of text with the string 'EXPIRY' (or any other existing INSERTANS field for that matter) ? Then it would always replace the strings with their value counterparts, no ? |
|
1st : strftime don't exist. 2nd : IN GUI too : EXPIRY is not replaced with EM. |
|
Fix committed to master branch: http://bugs.limesurvey.org/plugin.php?page=Source/view&id=16446 |
|
2.06 |
|
Version 2.50+ Build 140413 released |
|
LimeSurvey: master e30ac928 2015-12-09 17:26 Details Diff |
New feature 09904 : allow to use EXPIRY in expression when sending email Dev: Think SURVEYNAME/ADMINNAM etc ... don't have to be used Dev: maybe adding it when have same function for GUI and for RC |
Affected Issues 09904 |
|
mod - application/controllers/admin/tokens.php | Diff File | ||
mod - application/helpers/admin/token_helper.php | Diff File |
Date Modified | Username | Field | Change |
---|---|---|---|
2015-09-20 23:46 | oenie | New Issue | |
2015-09-30 13:16 | c_schmitz | Assigned To | => c_schmitz |
2015-09-30 13:16 | c_schmitz | Status | new => assigned |
2015-09-30 13:16 | c_schmitz | Note Added: 33249 | |
2015-09-30 13:16 | c_schmitz | Status | assigned => feedback |
2015-09-30 15:23 | oenie | Note Added: 33260 | |
2015-09-30 15:23 | oenie | Status | feedback => assigned |
2015-09-30 18:32 | oenie | Note Added: 33267 | |
2015-10-20 16:27 | oenie | File Added: issue_9904_expiry_token_remote_control.diff | |
2015-10-20 16:28 | oenie | Note Added: 33401 | |
2015-10-29 00:06 | oenie | Note Added: 33462 | |
2015-12-09 10:04 | c_schmitz | Assigned To | c_schmitz => DenisChenu |
2015-12-09 11:14 | DenisChenu | Note Added: 33793 | |
2015-12-09 11:18 | oenie | Note Added: 33794 | |
2015-12-09 11:29 | DenisChenu | Note Added: 33798 | |
2015-12-09 11:37 | oenie | Note Added: 33800 | |
2015-12-09 16:51 | DenisChenu | Note Added: 33820 | |
2015-12-09 16:51 | DenisChenu | Project | Bug reports => Feature requests |
2015-12-09 16:58 | DenisChenu | Severity | @50@ => feature |
2015-12-09 16:58 | DenisChenu | Summary | Variable EXPIRY of the survey is not found when used in an e-mail template that is sent through the Remote Control API => Variable EXPIRY of the survey can not be used in Expression when sending an email |
2015-12-09 17:27 | DenisChenu | Changeset attached | => LimeSurvey master e30ac928 |
2015-12-09 17:27 | DenisChenu | Note Added: 33826 | |
2015-12-09 17:27 | DenisChenu | Resolution | open => fixed |
2015-12-09 17:27 | DenisChenu | Note Added: 33827 | |
2015-12-09 17:27 | DenisChenu | Status | assigned => resolved |
2016-04-12 10:48 | c_schmitz | Note Added: 37245 | |
2016-04-12 10:48 | c_schmitz | Status | resolved => closed |