Commit 1371d861 authored by Chenu Denis's avatar Chenu Denis

[fix] LimeSurvey 3.X version

parent 921e0c9a
......@@ -2,17 +2,30 @@
Add for your admin user a question setting to put javascript snipet added when loading this question.
This add a new advanced setting in all question where user can just put javascript. Usage of {QID} and {SGQ} is allowed.
- **Compatibility** : Need [LS-SondagesPro](https://github.com/SondagesPro/LimeSurvey-SondagesPro) release 1.1.0 and up or with [LimeSurvey](https://www.limesurvey.org/) 2.50_plus_160731 and up.
- With LimeSurvey 2.63 version : you must use 1.0.2
- **filterxsshtml** : [filterxsshtml](https://manual.limesurvey.org/Optional_settings#Security) is not taken in account when loading attribute.
## Installation
### Via GIT
- Go to your LimeSurvey Directory
- Clone in plugins/addScriptToQuestion directory : `git clone https://git.framasoft.org/SondagePro-LimeSurvey-plugin/addScriptToQuestion.git addScriptToQuestion`
- Clone in plugins/addScriptToQuestion directory : `git clone https://gitlab.com/SondagesPro/addScriptToQuestion.git addScriptToQuestion`
### Via ZIP dowload
- Get the file [addScriptToQuestion.zip](https://extensions.sondages.pro/IMG/auto/addScriptToQuestion.zip)
- Extract : `unzip addScriptToQuestion.zip`
- Move the directory to plugins/ directory inside LimeSurvey
## Home page & Copyright
- HomePage <http://extensions.sondages.pro/>
- Copyright © 2016 Denis Chenu <http://sondages.pro>
- Licence : GNU Affero General Public License <https://www.gnu.org/licenses/agpl-3.0.html>
## Changelog
- 2018-03-08 [2.0.0] LimeSurvey 3.X version (tested on 3.4.4)
- 2017-06-27 [1.0.2] Fix {SGQ} replacement
- 2017-02-20 [1.0.0] Some fix, and compatibility
- 2016-11-17 [0.1.0] Release
......@@ -4,9 +4,9 @@
* @todo Show (and update/add) the settings according to XSS
*
* @author Denis Chenu <denis@sondages.pro>
* @copyright 2016 Denis Chenu <http://www.sondages.pro>
* @copyright 2016-2018 Denis Chenu <http://www.sondages.pro>
* @license AGPL v3
* @version 1.0.2
* @version 2.0.0
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
......@@ -18,7 +18,7 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
class addScriptToQuestion extends \ls\pluginmanager\PluginBase
class addScriptToQuestion extends PluginBase
{
static protected $name = 'addScriptToQuestion';
......@@ -67,7 +67,11 @@ class addScriptToQuestion extends \ls\pluginmanager\PluginBase
'QID'=>$oEvent->get('qid'),
'SGQ'=>$oEvent->get('surveyId')."X".$oEvent->get('gid')."X".$oEvent->get('qid'),
);
$script=LimeExpressionManager::ProcessString($aAttributes['javascript'], $oEvent->get('qid'), $aReplacement, false, 1, 1, false, false, true);
if(intval(Yii::app()->getConfig('version')) >=3) {
$script=LimeExpressionManager::ProcessString($aAttributes['javascript'], $oEvent->get('qid'), $aReplacement, 2, 0, false, false, true);
} else {
$script=LimeExpressionManager::ProcessString($aAttributes['javascript'], $oEvent->get('qid'), $aReplacement, false, 2, 0, false, false, true);
}
$aAttributes['scriptPosition']=isset($aAttributes['scriptPosition']) ? $aAttributes['scriptPosition'] : CClientScript::POS_END;
App()->getClientScript()->registerScript("scriptAttribute{$oEvent->get('qid')}",$script,$aAttributes['scriptPosition']);
}
......@@ -86,6 +90,7 @@ class addScriptToQuestion extends \ls\pluginmanager\PluginBase
'inputtype'=>'textarea',
'default'=>'', /* not needed (it's already the default) */
'expression'=>1,/* As static */
'readonly'=>Yii::app()->getConfig('filterxsshtml') && !Permission::model()->hasGlobalPermission('superadmin', 'read'),
'help'=>gT('You don\'t have to add script tag, script is register by LimeSurvey. You can use Expression, this expression is static (no update during runtime).'),
'caption'=>gT('Javascript for this question'),
),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment